Skip to content

Commit

Permalink
BUG/MINOR: ssl: can't load a separated key file with openssl > 3.0
Browse files Browse the repository at this point in the history
ssl_sock_load_pem_into_ckch() tries to load a PrivateKey with
PEM_read_bio_PrivateKey in the PEM file. However the key might be in
another file, and this might fill the error queue. In previous version
of OpenSSL it wasn't a problem because the error was a
PEM_R_NO_START_LINE which was ignored after, but some new versions
(3.0.13 from ubuntu or newer versions) emits another error
(error:1E08010C:DECODER routines::unsupported).

The problem is fixed by clearing the OpenSSL error stack after trying to
load optionnal content (Private key or DH).

This is a fix for version 2.4 only, version 2.6 does not have this
problem because c76c3c4 ("MEDIUM: ssl: Replace all DH objects by
EVP_PKEY on OpenSSLv3 (via HASSL_DH type)") added a ERR_clear_error()
but it should have been a separated bugfix. Should fix issue haproxy#2791.
  • Loading branch information
wlallemand committed Dec 2, 2024
1 parent 6b47cb7 commit d03501c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ssl_ckch.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ int ssl_sock_load_pem_into_ckch(const char *path, char *buf, struct cert_key_and
dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
/* no need to return an error there, dh is not mandatory */
#endif
ERR_clear_error();

/* Seek back to beginning of file */
if (BIO_reset(in) == -1) {
Expand Down

0 comments on commit d03501c

Please sign in to comment.