From e99550b86a6e5dacc31ad596bcfe638223654cc8 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 20 Jan 2023 12:00:10 +0100 Subject: [PATCH] libssl: Use decltype(&SSL_CTX_free) as suggested by Fred --- pdns/libssl.cc | 12 ++++++------ pdns/libssl.hh | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 2966e2b1b4..1103325708 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -317,7 +317,7 @@ static void libssl_info_callback(const SSL *ssl, int where, int ret) } } -void libssl_set_error_counters_callback(std::unique_ptr& ctx, TLSErrorCounters* counters) +void libssl_set_error_counters_callback(std::unique_ptr& ctx, TLSErrorCounters* counters) { SSL_CTX_set_ex_data(ctx.get(), s_countersIndex, counters); SSL_CTX_set_info_callback(ctx.get(), libssl_info_callback); @@ -482,7 +482,7 @@ bool libssl_generate_ocsp_response(const std::string& certFile, const std::strin #endif /* HAVE_OCSP_BASIC_SIGN */ #endif /* DISABLE_OCSP_STAPLING */ -static int libssl_get_last_key_type(std::unique_ptr& ctx) +static int libssl_get_last_key_type(std::unique_ptr& ctx) { #ifdef HAVE_SSL_CTX_GET0_PRIVATEKEY auto pkey = SSL_CTX_get0_privatekey(ctx.get()); @@ -534,7 +534,7 @@ const std::string& libssl_tls_version_to_string(LibsslTLSVersion version) return it->second; } -bool libssl_set_min_tls_version(std::unique_ptr& ctx, LibsslTLSVersion version) +bool libssl_set_min_tls_version(std::unique_ptr& ctx, LibsslTLSVersion version) { #if defined(HAVE_SSL_CTX_SET_MIN_PROTO_VERSION) || defined(SSL_CTX_set_min_proto_version) /* These functions have been introduced in 1.1.0, and the use of SSL_OP_NO_* is deprecated @@ -803,8 +803,8 @@ bool OpenSSLTLSTicketKey::decrypt(const unsigned char* iv, EVP_CIPHER_CTX* ectx, return true; } -std::pair, std::vector> libssl_init_server_context(const TLSConfig& config, - std::map& ocspResponses) +std::pair, std::vector> libssl_init_server_context(const TLSConfig& config, + std::map& ocspResponses) { std::vector warnings; auto ctx = std::unique_ptr(SSL_CTX_new(SSLv23_server_method()), SSL_CTX_free); @@ -1012,7 +1012,7 @@ static void libssl_key_log_file_callback(const SSL* ssl, const char* line) } #endif /* HAVE_SSL_CTX_SET_KEYLOG_CALLBACK */ -std::unique_ptr libssl_set_key_log_file(std::unique_ptr& ctx, const std::string& logFile) +std::unique_ptr libssl_set_key_log_file(std::unique_ptr& ctx, const std::string& logFile) { #ifdef HAVE_SSL_CTX_SET_KEYLOG_CALLBACK int fd = open(logFile.c_str(), O_WRONLY | O_CREAT | O_APPEND, 0600); diff --git a/pdns/libssl.hh b/pdns/libssl.hh index ad6bcd8133..1af3ff8a47 100644 --- a/pdns/libssl.hh +++ b/pdns/libssl.hh @@ -138,18 +138,18 @@ bool libssl_generate_ocsp_response(const std::string& certFile, const std::strin #endif #endif /* DISABLE_OCSP_STAPLING */ -void libssl_set_error_counters_callback(std::unique_ptr& ctx, TLSErrorCounters* counters); +void libssl_set_error_counters_callback(std::unique_ptr& ctx, TLSErrorCounters* counters); LibsslTLSVersion libssl_tls_version_from_string(const std::string& str); const std::string& libssl_tls_version_to_string(LibsslTLSVersion version); -bool libssl_set_min_tls_version(std::unique_ptr& ctx, LibsslTLSVersion version); +bool libssl_set_min_tls_version(std::unique_ptr& ctx, LibsslTLSVersion version); /* return the created context, and a list of warning messages for issues not severe enough to trigger raising an exception, like failing to load an OCSP response file */ -std::pair, std::vector> libssl_init_server_context(const TLSConfig& config, +std::pair, std::vector> libssl_init_server_context(const TLSConfig& config, std::map& ocspResponses); -std::unique_ptr libssl_set_key_log_file(std::unique_ptr& ctx, const std::string& logFile); +std::unique_ptr libssl_set_key_log_file(std::unique_ptr& ctx, const std::string& logFile); /* called in a client context, if the client advertised more than one ALPN values and the server returned more than one as well, to select the one to use. */ #ifndef DISABLE_NPN -- 2.47.2