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: d51939f2c4 ("DPP: Move CSR routines to use crypto.h")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2021-11-03 16:02:07 +02:00 committed by Jouni Malinen
parent fa193c1a73
commit 8f4d7e8f06

View file

@ -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;
}