From badffb66f8396fbe04fa2da91ad901c73f02c99a Mon Sep 17 00:00:00 2001 From: Mark Wright Date: Sat, 28 Oct 2017 16:28:03 +1100 Subject: [PATCH] Declare X509_set1_notBefore macro for OpenSSL 1.0 and LibreSSL. rhenium requested in review (thanks): I'd define macro in ext/openssl/openssl_missing.h. It's actually done for the getter functions, but apparently I forgot to do that for the setters. #define X509_set1_notBefore(x, t) X509_set_notBefore(x, t). --- ext/openssl/openssl_missing.h | 2 ++ ext/openssl/ossl_x509cert.c | 8 -------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h index cc31f6ace..2689be659 100644 --- a/ext/openssl/openssl_missing.h +++ b/ext/openssl/openssl_missing.h @@ -209,6 +209,8 @@ IMPL_PKEY_GETTER(EC_KEY, ec) # define X509_get0_notAfter(x) X509_get_notAfter(x) # define X509_CRL_get0_lastUpdate(x) X509_CRL_get_lastUpdate(x) # define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x) +# define X509_set1_notBefore(x, t) X509_set_notBefore(x, t) +# define X509_set1_notAfter(x, t) X509_set_notAfter(x, t) #endif #if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION) diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c index aeb1b3e01..05cc8a2d3 100644 --- a/ext/openssl/ossl_x509cert.c +++ b/ext/openssl/ossl_x509cert.c @@ -440,11 +440,7 @@ ossl_x509_set_not_before(VALUE self, VALUE time) GetX509(self, x509); asn1time = ossl_x509_time_adjust(NULL, time); -#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100000L) if (!X509_set1_notBefore(x509, asn1time)) { -#else - if (!X509_set_notBefore(x509, asn1time)) { -#endif ASN1_TIME_free(asn1time); ossl_raise(eX509CertError, "X509_set_notBefore"); } @@ -483,11 +479,7 @@ ossl_x509_set_not_after(VALUE self, VALUE time) GetX509(self, x509); asn1time = ossl_x509_time_adjust(NULL, time); -#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100000L) if (!X509_set1_notAfter(x509, asn1time)) { -#else - if (!X509_set_notAfter(x509, asn1time)) { -#endif ASN1_TIME_free(asn1time); ossl_raise(eX509CertError, "X509_set_notAfter"); }