Skip to content

Commit 3738434

Browse files
wlallemanda-denoyelle
authored andcommitted
BUG/MEDIUM: ssl: wrong priority whem limiting ECDSA ciphers in ECDSA+RSA configuration
The ClientHello Callback which is used for certificate selection uses both the signature algorithms and the ciphers sent by the client. However, when a client is announcing both ECDSA and RSA capabilities with ECSDA ciphers that are not available on haproxy side and RSA ciphers that are compatibles, the ECDSA certificate will still be used but this will result in a "no shared cipher" error, instead of a fallback on the RSA certificate. For example, a client could send 'ECDHE-ECDSA-AES128-CCM:ECDHE-RSA-AES256-SHA and HAProxy could be configured with only 'ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA'. This patch fixes the issue by validating that at least one ECDSA cipher is available on both side before chosing the ECDSA certificate. This must be backported on all stable versions. (cherry picked from commit 93cc23a) Signed-off-by: Amaury Denoyelle <[email protected]>
1 parent 96aef29 commit 3738434

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ssl_sock.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,10 +2268,14 @@ int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
22682268
}
22692269
if (has_ecdsa_sig) { /* in very rare case: has ecdsa sign but not a ECDSA cipher */
22702270
const SSL_CIPHER *cipher;
2271+
STACK_OF(SSL_CIPHER) *ha_ciphers; /* haproxy side ciphers */
22712272
uint32_t cipher_id;
22722273
size_t len;
22732274
const uint8_t *cipher_suites;
2275+
2276+
ha_ciphers = SSL_get_ciphers(ssl);
22742277
has_ecdsa_sig = 0;
2278+
22752279
#ifdef OPENSSL_IS_BORINGSSL
22762280
len = ctx->cipher_suites_len;
22772281
cipher_suites = ctx->cipher_suites;
@@ -2290,6 +2294,10 @@ int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
22902294
if (!cipher)
22912295
continue;
22922296

2297+
/* check if this cipher is available in haproxy configuration */
2298+
if (sk_SSL_CIPHER_find(ha_ciphers, cipher) == -1)
2299+
continue;
2300+
22932301
cipher_id = SSL_CIPHER_get_id(cipher);
22942302
/* skip the SCSV "fake" signaling ciphersuites because they are NID_auth_any (RFC 7507) */
22952303
if (cipher_id == SSL3_CK_SCSV || cipher_id == SSL3_CK_FALLBACK_SCSV)

0 commit comments

Comments
 (0)