changeset 21477:15eafce831ed

lib-ssl-iostream: Use ASN1_STRING_get0_data() if it exists This avoids deprecation warnings about ASN1_STRING_data() in OpenSSL v1.1.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Feb 2017 21:56:20 +0200
parents 75ff4f96cdc4
children 25414f008456
files configure.ac src/lib-ssl-iostream/iostream-openssl-common.c src/lib-ssl-iostream/iostream-openssl.h
diffstat 3 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Sun Feb 05 21:51:29 2017 +0200
+++ b/configure.ac	Sun Feb 05 21:56:20 2017 +0200
@@ -1759,6 +1759,9 @@
     AC_CHECK_LIB(ssl, RSA_generate_key_ex, [
       AC_DEFINE(HAVE_RSA_GENERATE_KEY_EX,, [Build with RSA_generate_key_ex() support])
     ],, $SSL_LIBS)
+    AC_CHECK_LIB(ssl, ASN1_STRING_get0_data, [
+      AC_DEFINE(HAVE_ASN1_STRING_GET0_DATA,, [Build with ASN1_STRING_get0_data() support])
+    ],, $SSL_LIBS)
     AC_CHECK_LIB(ssl, [EVP_PKEY_CTX_new_id], [have_evp_pkey_ctx_new_id="yes"],, $SSL_LIBS)
     AC_CHECK_LIB(ssl, [EC_KEY_new], [have_ec_key_new="yes"],, $SSL_LIBS)
     if test "$have_evp_pkey_ctx_new_id" = "yes" && test "$have_ec_key_new" = "yes"; then
--- a/src/lib-ssl-iostream/iostream-openssl-common.c	Sun Feb 05 21:51:29 2017 +0200
+++ b/src/lib-ssl-iostream/iostream-openssl-common.c	Sun Feb 05 21:56:20 2017 +0200
@@ -84,7 +84,7 @@
 	unsigned int len;
 
 	len = ASN1_STRING_length(asn_str);
-	cstr = t_strndup(ASN1_STRING_data(asn_str), len);
+	cstr = t_strndup(ASN1_STRING_get0_data(asn_str), len);
 	if (strlen(cstr) != len) {
 		/* NULs in the name - could be some MITM attack.
 		   never allow. */
--- a/src/lib-ssl-iostream/iostream-openssl.h	Sun Feb 05 21:51:29 2017 +0200
+++ b/src/lib-ssl-iostream/iostream-openssl.h	Sun Feb 05 21:56:20 2017 +0200
@@ -5,6 +5,10 @@
 
 #include <openssl/ssl.h>
 
+#ifndef HAVE_ASN1_STRING_GET0_DATA
+#  define ASN1_STRING_get0_data(str) ASN1_STRING_data(str)
+#endif
+
 struct ssl_iostream_context {
 	SSL_CTX *ssl_ctx;