From 86048989b2460d1dd762037449f8c9a9f6d35d3a Mon Sep 17 00:00:00 2001 From: rhe Date: Mon, 29 Aug 2016 05:47:09 +0000 Subject: import Ruby/OpenSSL 2.0.0.beta.1 * NEWS, {ext,test,sample}/openssl: Import Ruby/OpenSSL 2.0.0.beta.1. ext/openssl is now converted into a default gem. The full commit history since r55538 can be found at: https://github.com/ruby/openssl/compare/08e1881f5663...v2.0.0.beta.1 [Feature #9612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_x509cert.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'ext/openssl/ossl_x509cert.c') diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c index a7e37960e5..ad1126d465 100644 --- a/ext/openssl/ossl_x509cert.c +++ b/ext/openssl/ossl_x509cert.c @@ -456,10 +456,10 @@ static VALUE ossl_x509_get_not_before(VALUE self) { X509 *x509; - ASN1_UTCTIME *asn1time; + const ASN1_TIME *asn1time; GetX509(self, x509); - if (!(asn1time = X509_get_notBefore(x509))) { /* NO DUP - don't free! */ + if (!(asn1time = X509_get0_notBefore(x509))) { ossl_raise(eX509CertError, NULL); } @@ -474,10 +474,15 @@ static VALUE ossl_x509_set_not_before(VALUE self, VALUE time) { X509 *x509; + ASN1_TIME *asn1time; GetX509(self, x509); - if (!ossl_x509_time_adjust(X509_get_notBefore(x509), time)) - ossl_raise(eX509CertError, NULL); + asn1time = ossl_x509_time_adjust(NULL, time); + if (!X509_set_notBefore(x509, asn1time)) { + ASN1_TIME_free(asn1time); + ossl_raise(eX509CertError, "X509_set_notBefore"); + } + ASN1_TIME_free(asn1time); return time; } @@ -490,10 +495,10 @@ static VALUE ossl_x509_get_not_after(VALUE self) { X509 *x509; - ASN1_TIME *asn1time; + const ASN1_TIME *asn1time; GetX509(self, x509); - if (!(asn1time = X509_get_notAfter(x509))) { /* NO DUP - don't free! */ + if (!(asn1time = X509_get0_notAfter(x509))) { ossl_raise(eX509CertError, NULL); } @@ -508,10 +513,15 @@ static VALUE ossl_x509_set_not_after(VALUE self, VALUE time) { X509 *x509; + ASN1_TIME *asn1time; GetX509(self, x509); - if (!ossl_x509_time_adjust(X509_get_notAfter(x509), time)) - ossl_raise(eX509CertError, NULL); + asn1time = ossl_x509_time_adjust(NULL, time); + if (!X509_set_notAfter(x509, asn1time)) { + ASN1_TIME_free(asn1time); + ossl_raise(eX509CertError, "X509_set_notAfter"); + } + ASN1_TIME_free(asn1time); return time; } @@ -667,13 +677,10 @@ ossl_x509_set_extensions(VALUE self, VALUE ary) while ((ext = X509_delete_ext(x509, 0))) X509_EXTENSION_free(ext); for (i=0; i