From: Charles-Henri Bruyand Date: Fri, 17 Dec 2021 09:39:07 +0000 (+0100) Subject: libssl: fix missing SSL_CTX_use_cert_and_key function on openssl version < 1.1.1... X-Git-Tag: auth-4.7.0-alpha1~110^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87689617f03c57457b46a4d9d01a93c9e0f0bcf1;p=thirdparty%2Fpdns.git libssl: fix missing SSL_CTX_use_cert_and_key function on openssl version < 1.1.1 by disabling pkcs12 support --- diff --git a/m4/pdns_with_libssl.m4 b/m4/pdns_with_libssl.m4 index 3e32bc4086..28b32d59b2 100644 --- a/m4/pdns_with_libssl.m4 +++ b/m4/pdns_with_libssl.m4 @@ -17,7 +17,7 @@ AC_DEFUN([PDNS_WITH_LIBSSL], [ save_LIBS=$LIBS CFLAGS="$LIBSSL_CFLAGS $CFLAGS" LIBS="$LIBSSL_LIBS -lcrypto $LIBS" - AC_CHECK_FUNCS([SSL_CTX_set_ciphersuites OCSP_basic_sign SSL_CTX_set_num_tickets SSL_CTX_set_keylog_callback SSL_CTX_get0_privatekey SSL_CTX_set_min_proto_version SSL_set_hostflags SSL_CTX_set_alpn_protos SSL_CTX_set_next_proto_select_cb SSL_get0_alpn_selected SSL_get0_next_proto_negotiated SSL_CTX_set_alpn_select_cb]) + AC_CHECK_FUNCS([SSL_CTX_set_ciphersuites OCSP_basic_sign SSL_CTX_set_num_tickets SSL_CTX_set_keylog_callback SSL_CTX_get0_privatekey SSL_CTX_set_min_proto_version SSL_set_hostflags SSL_CTX_set_alpn_protos SSL_CTX_set_next_proto_select_cb SSL_get0_alpn_selected SSL_get0_next_proto_negotiated SSL_CTX_set_alpn_select_cb SSL_CTX_use_cert_and_key]) CFLAGS=$save_CFLAGS LIBS=$save_LIBS diff --git a/pdns/libssl.cc b/pdns/libssl.cc index d5fb6d42bc..3312d9de94 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -787,6 +787,7 @@ std::unique_ptr libssl_init_server_context(const TLS /* load certificate and private key */ for (const auto& pair : config.d_certKeyPairs) { if (!pair.d_key) { +#if defined(HAVE_SSL_CTX_USE_CERT_AND_KEY) && HAVE_SSL_CTX_USE_CERT_AND_KEY == 1 && defined(sk_X509_free) // If no separate key is given, treat it as a pkcs12 file auto fp = std::unique_ptr(fopen(pair.d_cert.c_str(), "r"), fclose); if (!fp) { @@ -812,6 +813,9 @@ std::unique_ptr libssl_init_server_context(const TLS ERR_print_errors_fp(stderr); throw std::runtime_error("An error occurred while trying to load the TLS certificate and key from PKCS12 file " + pair.d_cert); } +#else + throw std::runtime_error("PKCS12 files are not supported by your openssl version"); +#endif /* HAVE_SSL_CTX_USE_CERT_AND_KEY */ } else { if (SSL_CTX_use_certificate_chain_file(ctx.get(), pair.d_cert.c_str()) != 1) { ERR_print_errors_fp(stderr);