summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Lallemand <wlallemand@haproxy.org>2021-11-18 17:46:26 +0100
committerWilliam Lallemand <wlallemand@haproxy.org>2021-11-18 19:35:17 +0100
commitd97d60ff0741c51eee30f45f5b6a896ef1ad2335 (patch)
tree3eca9e39e315e1d48503db754f9c5273b826f70a
parentb742d8812777547424e20b87fc88e587777d9bb1 (diff)
downloadhaproxy-d97d60ff0741c51eee30f45f5b6a896ef1ad2335.tar.gz
BUG/MEDIUM: ssl: abort with the correct SSL error when SNI not found
Since commit c2aae74 ("MEDIUM: ssl: Handle early data with OpenSSL 1.1.1"), the codepath of the clientHello callback changed, letting a unknown SNI escaped with a 'return 1' instead of passing through the abort label. This patch switch the code path of the allow_early and abort label, so the default code path is the abort one, letting the clientHello return the correct SSL_AD_UNRECOGNIZED_NAME in case of errors. Which means the client will now receive: OpenSSL error[0x14094458] ssl3_read_bytes: tlsv1 unrecognized name Instead of: OpenSSL error[0x14094410] ssl3_read_bytes: sslv3 alert handshake failure Which was the error emitted before HAProxy 1.8. This patch must be carrefuly backported as far as 1.8 once we validate its impact.
-rw-r--r--src/ssl_sock.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 42a4772e9..6dd0ce689 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -2679,16 +2679,11 @@ int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
HA_RWLOCK_RDLOCK(SNI_LOCK, &s->sni_lock);
ssl_sock_switchctx_set(ssl, s->default_ctx);
HA_RWLOCK_RDUNLOCK(SNI_LOCK, &s->sni_lock);
+ goto allow_early;
}
-allow_early:
-#ifdef OPENSSL_IS_BORINGSSL
- if (allow_early)
- SSL_set_early_data_enabled(ssl, 1);
-#else
- if (!allow_early)
- SSL_set_max_early_data(ssl, 0);
-#endif
- return 1;
+
+ /* other cases fallback on abort, if strict-sni is set but no node was found */
+
abort:
/* abort handshake (was SSL_TLSEXT_ERR_ALERT_FATAL) */
conn->err_code = CO_ER_SSL_HANDSHAKE;
@@ -2698,6 +2693,16 @@ allow_early:
*al = SSL_AD_UNRECOGNIZED_NAME;
return 0;
#endif
+
+allow_early:
+#ifdef OPENSSL_IS_BORINGSSL
+ if (allow_early)
+ SSL_set_early_data_enabled(ssl, 1);
+#else
+ if (!allow_early)
+ SSL_set_max_early_data(ssl, 0);
+#endif
+ return 1;
}
#else /* ! HAVE_SSL_CLIENT_HELLO_CB */