MINOR: ssl: Remove call to ERR_func_error_string with OpenSSLv3

ERR_func_error_string does not return anything anymore with OpenSSLv3,
it can be replaced by ERR_peek_error_func which did not exist on
previous versions.
This commit is contained in:
Remi Tricot-Le Breton 2022-02-11 12:04:44 +01:00 committed by William Lallemand
parent 7b820a6191
commit 1effd9aa09
2 changed files with 20 additions and 1 deletions

View File

@ -314,6 +314,22 @@ static inline X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx)
#if defined(SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB) #if defined(SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB)
#define SSL_CTX_set_tlsext_ticket_key_evp_cb SSL_CTX_set_tlsext_ticket_key_cb #define SSL_CTX_set_tlsext_ticket_key_evp_cb SSL_CTX_set_tlsext_ticket_key_cb
#endif #endif
/*
* Functions introduced in OpenSSL 3.0.0
*/
static inline unsigned long ERR_peek_error_func(const char **func)
{
unsigned long ret = ERR_peek_error();
if (ret == 0)
return ret;
if (func)
*func = ERR_func_error_string(ret);
return ret;
}
#endif #endif
#if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070200fL) #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070200fL)

View File

@ -608,12 +608,15 @@ static forceinline void ssl_sock_dump_errors(struct connection *conn)
if (unlikely(global.mode & MODE_DEBUG)) { if (unlikely(global.mode & MODE_DEBUG)) {
while(1) { while(1) {
const char *func = NULL;
ERR_peek_error_func(&func);
ret = ERR_get_error(); ret = ERR_get_error();
if (ret == 0) if (ret == 0)
return; return;
fprintf(stderr, "fd[%#x] OpenSSL error[0x%lx] %s: %s\n", fprintf(stderr, "fd[%#x] OpenSSL error[0x%lx] %s: %s\n",
conn->handle.fd, ret, conn->handle.fd, ret,
ERR_func_error_string(ret), ERR_reason_error_string(ret)); func, ERR_reason_error_string(ret));
} }
} }
} }