openssl: Don't use functions deprecated with OpenSSL 1.1.0
authorTobias Brunner <tobias@strongswan.org>
Tue, 30 Oct 2018 15:55:32 +0000 (16:55 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 31 Oct 2018 14:50:36 +0000 (15:50 +0100)
src/libstrongswan/plugins/openssl/openssl_crl.c
src/libstrongswan/plugins/openssl/openssl_util.c

index bb5f20d..3f5a7a6 100644 (file)
@@ -57,6 +57,9 @@ static inline void X509_CRL_get0_signature(const X509_CRL *crl, ASN1_BIT_STRING
 #define X509_REVOKED_get0_serialNumber(r) ({ (r)->serialNumber; })
 #define X509_REVOKED_get0_revocationDate(r) ({ (r)->revocationDate; })
 #define X509_CRL_get0_extensions(c) ({ (c)->crl->extensions; })
+#define ASN1_STRING_get0_data(a) ASN1_STRING_data(a)
+#define X509_CRL_get0_lastUpdate(c) X509_CRL_get_lastUpdate(c)
+#define X509_CRL_get0_nextUpdate(c) X509_CRL_get_nextUpdate(c)
 #endif
 
 typedef struct private_openssl_crl_t private_openssl_crl_t;
@@ -193,7 +196,7 @@ METHOD(enumerator_t, crl_enumerate, bool,
                                if (ASN1_STRING_type(crlrsn) == V_ASN1_ENUMERATED &&
                                        ASN1_STRING_length(crlrsn) == 1)
                                {
-                                       *reason = *ASN1_STRING_data(crlrsn);
+                                       *reason = *ASN1_STRING_get0_data(crlrsn);
                                }
                                ASN1_STRING_free(crlrsn);
                        }
@@ -588,8 +591,8 @@ static bool parse_crl(private_openssl_crl_t *this)
        {
                return FALSE;
        }
-       this->thisUpdate = openssl_asn1_to_time(X509_CRL_get_lastUpdate(this->crl));
-       this->nextUpdate = openssl_asn1_to_time(X509_CRL_get_nextUpdate(this->crl));
+       this->thisUpdate = openssl_asn1_to_time(X509_CRL_get0_lastUpdate(this->crl));
+       this->nextUpdate = openssl_asn1_to_time(X509_CRL_get0_nextUpdate(this->crl));
 
        return parse_extensions(this);
 }
index b7f969f..c336333 100644 (file)
@@ -26,6 +26,7 @@
 #if OPENSSL_VERSION_NUMBER < 0x10100000L
 #define OBJ_get0_data(o) ((o)->data)
 #define OBJ_length(o) ((o)->length)
+#define ASN1_STRING_get0_data(a) ASN1_STRING_data(a)
 #endif
 
 /**
@@ -168,7 +169,8 @@ chunk_t openssl_asn1_str2chunk(ASN1_STRING *asn1)
 {
        if (asn1)
        {
-               return chunk_create(ASN1_STRING_data(asn1), ASN1_STRING_length(asn1));
+               return chunk_create((u_char*)ASN1_STRING_get0_data(asn1),
+                                                       ASN1_STRING_length(asn1));
        }
        return chunk_empty;
 }