Skip to content

Commit

Permalink
refactor goto error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Jun 5, 2024
1 parent 325aaa4 commit 67630eb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/tls/openssl/sni.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ static int ssl_servername_handler(SSL *ssl, int *al, void *arg)
const char *sni;

sni = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
if (!str_isset(sni))
goto err;
if (!str_isset(sni)) {
*al = SSL_AD_UNRECOGNIZED_NAME;
return SSL_TLSEXT_ERR_ALERT_FATAL;
}

/* find and apply matching certificate */
uc = tls_cert_for_sni(tls, sni);
Expand All @@ -177,16 +179,14 @@ static int ssl_servername_handler(SSL *ssl, int *al, void *arg)
}

DEBUG_INFO("found cert for sni %s\n", sni);
if (SSL_set_SSL_CTX(ssl, tls_cert_ctx(uc)) == NULL)
goto err;
if (SSL_set_SSL_CTX(ssl, tls_cert_ctx(uc)) == NULL) {
*al = SSL_AD_INTERNAL_ERROR;
return SSL_TLSEXT_ERR_ALERT_FATAL;
}

(void)ssl_set_verify_client(ssl, tls_cert_host(uc));

return SSL_TLSEXT_ERR_OK;

err:
*al = SSL_AD_INTERNAL_ERROR;
return SSL_TLSEXT_ERR_ALERT_FATAL;
}


Expand Down

0 comments on commit 67630eb

Please sign in to comment.