aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_x509cert.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-26 01:53:27 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-26 02:12:37 +0900
commitbb170849428dab1463a8e6ec6109beb0d9da0058 (patch)
tree310d1b4d1e6082ddfc0bdf11ae44a673e2c56c26 /ext/openssl/ossl_x509cert.c
parenta3311831a1b16beea04cd716769def7bd9887bd3 (diff)
downloadruby-openssl-bb170849428dab1463a8e6ec6109beb0d9da0058.tar.gz
Adapt to OpenSSL changes after the 1.1.0-pre6
Fix compiler errors and warnings. The order of parameters of X509_{CRL,REQ}_get0_signature() has been changed, and certificate and CRL time accessors have been reorganized: *_get_* functions are deprecated and replaced by *_get0_* that return a const pointer.
Diffstat (limited to 'ext/openssl/ossl_x509cert.c')
-rw-r--r--ext/openssl/ossl_x509cert.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index 6ddb2303..ad1126d4 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;
}