Fix OpenSSL private key passphrase notices
PATCH 1/1 Fix OpenSSL private key passphrase notices
Clear error stack on successful certificate loading in tls_ctx_load_cert_file_and_copy() and handle errors also for PEM_read_bio_PrivateKey() call in tls_ctx_load_priv_file().
Due to certificate loading possibly leaking non-fatal errors on OpenSSL error stack, and some slight oversights in error handling, the
Quoted 1 line
PASSWORD:Verification Failed: 'Private Key'
line was never produced on the management channel for PEM formatted keys.
--- src/openvpn/ssl_openssl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
src/openvpn/ssl_openssl.c +5 -6
@@ -921,6 +921,10 @@ end:crypto_msg (M_FATAL ,"Cannot load certificate file %s" , cert_file); } } +else + { +crypto_print_openssl_errors (M_DEBUG ); + }if (in !=NULL ) {
@@ -963,12 +967,7 @@ tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file, pkey =PEM_read_bio_PrivateKey (in,NULL ,SSL_CTX_get_default_passwd_cb (ctx->ctx),SSL_CTX_get_default_passwd_cb_userdata (ctx->ctx)); -if (!pkey) - { - goto end; - } - -if (!SSL_CTX_use_PrivateKey (ssl_ctx, pkey)) +if (!pkey || !SSL_CTX_use_PrivateKey (ssl_ctx, pkey)) {#ifdef ENABLE_MANAGEMENT if (management && (ERR_GET_REASON (ERR_peek_error ()) ==EVP_R_BAD_DECRYPT ))
Signature · 1 line
2.20.1
Hi,
Quoted 36 lines · Santtu Lakkala
Clear error stack on successful certificate loading in
tls_ctx_load_cert_file_and_copy()and handle errors also forPEM_read_bio_PrivateKey()call intls_ctx_load_priv_file().Due to certificate loading possibly leaking non-fatal errors on OpenSSL error stack, and some slight oversights in error handling, the
Quoted 1 line
PASSWORD:Verification Failed: 'Private Key'
line was never produced on the management channel for PEM formatted keys.
Signed-off-by Santtu Lakkala <[email protected]...>--- src/openvpn/ssl_openssl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)src/openvpn/ssl_openssl.c +4
-0@@ -921,6 +921,10 @@ end:crypto_msg (M_FATAL ,"Cannot load certificate file %s" , cert_file); } } +else + { +crypto_print_openssl_errors (M_DEBUG ); + }if (in !=NULL ) {@@ -963,12 +967,7 @@ tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file, pkey =PEM_read_bio_PrivateKey (in,NULL ,SSL_CTX_get_default_passwd_cb (ctx->ctx),SSL_CTX_get_default_passwd_cb_userdata (ctx->ctx));
src/openvpn/ssl_openssl.c tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file, · line 973
Quoted 10 lines
src/openvpn/ssl_openssl.c +1
-6-if (!pkey) - { - goto end; - } - -if (!SSL_CTX_use_PrivateKey (ssl_ctx, pkey)) +if (!pkey || !SSL_CTX_use_PrivateKey (ssl_ctx, pkey)) {#ifdef ENABLE_MANAGEMENT if (management && (ERR_GET_REASON (ERR_peek_error ()) ==EVP_R_BAD_DECRYPT ))
Thanks, and apologies for the late repsonse. This patch does was it says, and looks good to me. I think this one should go into both master and release/2.4.
-Steffan
Your patch has been applied to the master and release/2.4 branch.
I haven't done any sort of qualified code review, but I have done a few test builds / t_client test runs, and all looks good. If Steffan says so, *and* it compiles, it's good enough for me anyway :-)
Sorry for the delay... "interesting times".
commit f67efa9412a62f477aa17c3179b7e9f31ac4b25f (master) commit 7d19b2bb7b4a4976bc720d72227ee79c440e06fc (release/2.4)
Author: Santtu Lakkala Date: Mon Oct 21 14:35:06 2019 +0300
Fix OpenSSL private key passphrase notices
Signed-off-by: Santtu Lakkala <[email protected]...>
Acked-by: Steffan Karger <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18953.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering