Skip to content

Commit be979dd

Browse files
wlallemandcapflam
authored andcommitted
BUG/MEDIUM: ssl: bad auth selection with TLS1.2 and WolfSSL
The ClientHello callback for WolfSSL introduced in haproxy 2.9, seems not to behave correctly with TLSv1.2. In TLSv1.2, this is the cipher that is used to chose the authentication algorithm (ECDSA or RSA), however an SSL client can send a signature algorithm. In TLSv1.3, the authentication is not part of the ciphersuites, and is selected using the signature algorithm. The mistake in the code is that the signature algorithm in TLSv1.2 are overwritting the auth that was selected using the ciphers. This must be backported as far as 2.9. (cherry picked from commit 711338e) Signed-off-by: Christopher Faulet <[email protected]>
1 parent 3738434 commit be979dd

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/ssl_sock.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,10 @@ static int ssl_sock_switchctx_wolfSSL_cbk(WOLFSSL* ssl, void* arg)
25642564
return 0;
25652565

25662566
if (SSL_version(ssl) != TLS1_3_VERSION) {
2567+
2568+
/* with TLS <= 1.2, we must use the auth which is provided by the cipher, but we don't need to
2569+
* consider the auth provided by the signature algorithms */
2570+
25672571
for (idx = 0; idx < suiteSz; idx += 2) {
25682572
WOLFSSL_CIPHERSUITE_INFO info;
25692573
info = wolfSSL_get_ciphersuite_info(suites[idx], suites[idx+1]);
@@ -2572,23 +2576,22 @@ static int ssl_sock_switchctx_wolfSSL_cbk(WOLFSSL* ssl, void* arg)
25722576
else if (info.eccAuth)
25732577
has_ecdsa_sig = 1;
25742578
}
2575-
}
2579+
} else {
2580+
/* with TLS >= 1.3, we must use the auth which is provided by the signature algorithms because
2581+
* the ciphers does not provide the auth */
25762582

2577-
if (hashSigAlgoSz > 0) {
2578-
/* sigalgs extension takes precedence over ciphersuites */
2579-
has_ecdsa_sig = 0;
2580-
has_rsa_sig = 0;
2581-
}
2582-
for (idx = 0; idx < hashSigAlgoSz; idx += 2) {
2583-
int hashAlgo;
2584-
int sigAlgo;
2583+
for (idx = 0; idx < hashSigAlgoSz; idx += 2) {
2584+
int hashAlgo;
2585+
int sigAlgo;
25852586

2586-
wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1], &hashAlgo, &sigAlgo);
2587+
wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1], &hashAlgo, &sigAlgo);
25872588

2588-
if (sigAlgo == RSAk || sigAlgo == RSAPSSk)
2589-
has_rsa_sig = 1;
2590-
else if (sigAlgo == ECDSAk)
2591-
has_ecdsa_sig = 1;
2589+
if (sigAlgo == RSAk || sigAlgo == RSAPSSk)
2590+
has_rsa_sig = 1;
2591+
else if (sigAlgo == ECDSAk)
2592+
has_ecdsa_sig = 1;
2593+
2594+
}
25922595
}
25932596
}
25942597

0 commit comments

Comments
 (0)