summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_ns_spki.c30
-rw-r--r--ext/openssl/ossl_ssl.c2
-rw-r--r--ext/openssl/ossl_x509req.c2
-rw-r--r--ext/openssl/ossl_x509store.c13
4 files changed, 40 insertions, 7 deletions
diff --git a/ext/openssl/ossl_ns_spki.c b/ext/openssl/ossl_ns_spki.c
index c4ad05dea34..5cba5298504 100644
--- a/ext/openssl/ossl_ns_spki.c
+++ b/ext/openssl/ossl_ns_spki.c
@@ -56,12 +56,17 @@ ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
{
NETSCAPE_SPKI *spki;
VALUE buffer;
+ unsigned char *p;
if (rb_scan_args(argc, argv, "01", &buffer) == 0) {
return self;
}
- if (!(spki = NETSCAPE_SPKI_b64_decode(StringValuePtr(buffer), -1))) {
- ossl_raise(eSPKIError, NULL);
+ StringValue(buffer);
+ if (!(spki = NETSCAPE_SPKI_b64_decode(RSTRING(buffer)->ptr, -1))) {
+ p = RSTRING(buffer)->ptr;
+ if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING(buffer)->len))) {
+ ossl_raise(eSPKIError, NULL);
+ }
}
NETSCAPE_SPKI_free(DATA_PTR(self));
DATA_PTR(self) = spki;
@@ -70,6 +75,26 @@ ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
}
static VALUE
+ossl_spki_to_der(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetSPKI(self, spki);
+ if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
ossl_spki_to_pem(VALUE self)
{
NETSCAPE_SPKI *spki;
@@ -217,6 +242,7 @@ Init_ossl_ns_spki()
rb_define_alloc_func(cSPKI, ossl_spki_alloc);
rb_define_method(cSPKI, "initialize", ossl_spki_initialize, -1);
+ rb_define_method(cSPKI, "to_der", ossl_spki_to_der, 0);
rb_define_method(cSPKI, "to_pem", ossl_spki_to_pem, 0);
rb_define_alias(cSPKI, "to_s", "to_pem");
rb_define_method(cSPKI, "to_text", ossl_spki_print, 0);
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 7a376223a97..5ae4cae56ff 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -477,7 +477,7 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
return Qnil;
}
if (!SSL_CTX_set_cipher_list(ctx, RSTRING(str)->ptr)) {
- ossl_raise(eSSLError, "SSL_CTX_set_ciphers:");
+ ossl_raise(eSSLError, "SSL_CTX_set_cipher_list:");
}
return v;
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index 35c520194af..d644250433a 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -400,7 +400,7 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
X509_REQ *req;
X509_ATTRIBUTE *attr;
int i;
- VALUE tmp, item;
+ VALUE item;
Check_Type(ary, T_ARRAY);
for (i=0;i<RARRAY(ary)->len; i++) {
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 5dba7338783..cea845a1cc5 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -137,6 +137,7 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
rb_iv_set(self, "@error", Qnil);
rb_iv_set(self, "@error_string", Qnil);
rb_iv_set(self, "@chain", Qnil);
+ rb_iv_set(self, "@time", Qnil);
return self;
}
@@ -244,7 +245,9 @@ ossl_x509store_set_default_paths(VALUE self)
X509_STORE *store;
GetX509Store(self, store);
- X509_STORE_set_default_paths(store);
+ if (X509_STORE_set_default_paths(store) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
return Qnil;
}
@@ -257,7 +260,9 @@ ossl_x509store_add_cert(VALUE self, VALUE arg)
cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
GetX509Store(self, store);
- X509_STORE_add_cert(store, cert);
+ if (X509_STORE_add_cert(store, cert) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
return self;
}
@@ -270,7 +275,9 @@ ossl_x509store_add_crl(VALUE self, VALUE arg)
crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
GetX509Store(self, store);
- X509_STORE_add_crl(store, crl);
+ if (X509_STORE_add_crl(store, crl) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
return self;
}