Skip to content

Commit

Permalink
tls/sni: skip SNI check if we are client
Browse files Browse the repository at this point in the history
The servername_callback is also called when the server requests a
certificate in the ServerHello. However, the server will not usually
send us the server_name extension. So skip the SNI check if we are
client.
  • Loading branch information
maximilianfridrich committed Jul 30, 2024
1 parent 80baf46 commit d8b8fae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tls/openssl/sni.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ static int ssl_servername_handler(SSL *ssl, int *al, void *arg)
{
struct tls *tls = arg;
struct tls_cert *uc = NULL;
int ssl_state = SSL_get_state(ssl);
const char *sni;

if (ssl_state == TLS_ST_CR_SRVR_HELLO)
return SSL_TLSEXT_ERR_OK;

sni = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
if (!str_isset(sni)) {
*al = SSL_AD_UNRECOGNIZED_NAME;
Expand Down

0 comments on commit d8b8fae

Please sign in to comment.