diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-02-13 13:09:26 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-02-13 13:09:26 +0000 |
commit | 5e2a679a46e2164f8b38b71132787c3327862957 (patch) | |
tree | 4ab99602f4f8adec2a96194abd4a39c48e0fab00 /ossl_x509ext.c | |
parent | 1ad093352e953cabd70c851989ce06edc233d5f4 (diff) | |
download | ruby-openssl-history-5e2a679a46e2164f8b38b71132787c3327862957.tar.gz |
* transition from rb_raise to OSSL_Raise (where possible)
* some mem checks
* preliminary DH key support
Diffstat (limited to 'ossl_x509ext.c')
-rw-r--r-- | ossl_x509ext.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/ossl_x509ext.c b/ossl_x509ext.c index 2a5bf33..30f9e05 100644 --- a/ossl_x509ext.c +++ b/ossl_x509ext.c @@ -1,7 +1,7 @@ /* * $Id$ * 'OpenSSL for Ruby' project - * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz> + * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz> * All rights reserved. */ /* @@ -65,33 +65,22 @@ ossl_x509extfactory_free(ossl_x509extfactory *extfactoryp) * Public */ VALUE -ossl_x509ext_new_null(void) -{ - ossl_x509ext *extp = NULL; - VALUE obj; - - MakeX509Ext(obj, extp); - - if (!(extp->extension = X509_EXTENSION_new())) - rb_raise(eX509ExtensionError, "%s", ossl_error()); - - return obj; -} - -VALUE ossl_x509ext_new(X509_EXTENSION *ext) { ossl_x509ext *extp = NULL; + X509_EXTENSION *new = NULL; VALUE obj; if (!ext) - return ossl_x509ext_new_null(); + new = X509_EXTENSION_new(); + else new = X509_EXTENSION_dup(ext); + if (!new) + OSSL_Raise(eX509ExtensionError, ""); + MakeX509Ext(obj, extp); + extp->extension = new; - if (!(extp->extension = X509_EXTENSION_dup(ext))) - rb_raise(eX509ExtensionError, "%s", ossl_error()); - return obj; } @@ -229,15 +218,16 @@ ossl_x509extfactory_create_ext_from_array(VALUE self, VALUE ary) rb_raise(eX509ExtensionError, "unsupported structure"); } if (!(ext = X509_EXTENSION_new())) { - rb_raise(eX509ExtensionError, "%s", ossl_error()); + OSSL_Raise(eX509ExtensionError, ""); } /* key [0] */ item = RARRAY(ary)->ptr[0]; Check_SafeStr(item); if (!(nid = OBJ_ln2nid(RSTRING(item)->ptr))) - if (!(nid = OBJ_sn2nid(RSTRING(item)->ptr))) - rb_raise(eX509ExtensionError, "%s", ossl_error()); + if (!(nid = OBJ_sn2nid(RSTRING(item)->ptr))) { + OSSL_Raise(eX509ExtensionError, ""); + } /* data [1] */ item = RARRAY(ary)->ptr[1]; @@ -255,7 +245,7 @@ ossl_x509extfactory_create_ext_from_array(VALUE self, VALUE ary) if (!(ext = X509V3_EXT_conf_nid(NULL, &(extfactoryp->ctx), nid, value))) { free(value); - rb_raise(eX509ExtensionError, "%s", ossl_error()); + OSSL_Raise(eX509ExtensionError, ""); } free(value); @@ -285,11 +275,11 @@ ossl_x509ext_to_a(VALUE obj) rb_ary_push(ary, rb_str_new2(OBJ_nid2sn(nid))); if (!(out = BIO_new(BIO_s_mem()))) { - rb_raise(eX509ExtensionError, "%s", ossl_error()); + OSSL_Raise(eX509ExtensionError, ""); } if (!X509V3_EXT_print(out, extp->extension, 0, 0)) { BIO_free(out); - rb_raise(eX509ExtensionError, "%s", ossl_error()); + OSSL_Raise(eX509ExtensionError, ""); } BIO_get_mem_ptr(out, &buf); value = rb_str_new(buf->data, buf->length); |