From 8f4d7e8f06dbfad05022b29d44ce70100a12583b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 3 Nov 2021 16:02:07 +0200 Subject: [PATCH] OpenSSL: Fix build with OpenSSL 1.0.2 OpenSSL 1.0.2 did not define the 'bytes' argument to X509_NAME_add_entry_by_NID() to be const like it did for the previously used X509_NAME_add_entry_by_txt(). Add a backwards compatible version of this call to avoid compilation issues. Fixes: d51939f2c4b5 ("DPP: Move CSR routines to use crypto.h") Signed-off-by: Jouni Malinen --- src/crypto/crypto_openssl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 98b93d9a7..ef669c408 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -3099,10 +3099,17 @@ int crypto_csr_set_name(struct crypto_csr *csr, enum crypto_csr_name type, if (!n) return -1; +#if OPENSSL_VERSION_NUMBER < 0x10100000L + if (!X509_NAME_add_entry_by_NID(n, nid, MBSTRING_UTF8, + (unsigned char *) name, + os_strlen(name), -1, 0)) + return -1; +#else if (!X509_NAME_add_entry_by_NID(n, nid, MBSTRING_UTF8, (const unsigned char *) name, os_strlen(name), -1, 0)) return -1; +#endif return 0; }