diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-05 15:49:38 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-05 15:49:38 +0000 |
commit | 2b620bec1280550b5503f37272032822646cc86d (patch) | |
tree | 9455069e90f6382a5e9468574290b69213afabc7 /ext | |
parent | 6c9e95df88d124a5fd0e7c996ce10b47471ee39d (diff) | |
download | ruby-2b620bec1280550b5503f37272032822646cc86d.tar.gz |
* ext/openssl/ossl_ocsp.c (ossl_ocspcid_initialize): an optional
parameter may be used to specify the OpenSSL::OCSP::CertificateId on
initialization. Thanks Elise Huard! [ruby-core:32460]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl_ocsp.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c index 1c53147a03..fb01243261 100644 --- a/ext/openssl/ossl_ocsp.c +++ b/ext/openssl/ossl_ocsp.c @@ -628,14 +628,27 @@ ossl_ocspcid_alloc(VALUE klass) } static VALUE -ossl_ocspcid_initialize(VALUE self, VALUE subject, VALUE issuer) +ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self) { OCSP_CERTID *id, *newid; X509 *x509s, *x509i; + VALUE subject, issuer, digest; + const EVP_MD *md; + + if (rb_scan_args(argc, argv, "21", &subject, &issuer, &digest) == 0) { + return self; + } x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */ x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */ - if(!(newid = OCSP_cert_to_id(NULL, x509s, x509i))) + + if (!NIL_P(digest)) { + md = GetDigestPtr(digest); + newid = OCSP_cert_to_id(md, x509s, x509i); + } else { + newid = OCSP_cert_to_id(NULL, x509s, x509i); + } + if(!newid) ossl_raise(eOCSPError, NULL); GetOCSPCertId(self, id); OCSP_CERTID_free(id); @@ -719,7 +732,7 @@ Init_ossl_ocsp() cOCSPCertId = rb_define_class_under(mOCSP, "CertificateId", rb_cObject); rb_define_alloc_func(cOCSPCertId, ossl_ocspcid_alloc); - rb_define_method(cOCSPCertId, "initialize", ossl_ocspcid_initialize, 2); + rb_define_method(cOCSPCertId, "initialize", ossl_ocspcid_initialize, -1); rb_define_method(cOCSPCertId, "cmp", ossl_ocspcid_cmp, 1); rb_define_method(cOCSPCertId, "cmp_issuer", ossl_ocspcid_cmp_issuer, 1); rb_define_method(cOCSPCertId, "serial", ossl_ocspcid_get_serial, 0); |