Skip to content

Commit

Permalink
move the sni check into handshaker create func
Browse files Browse the repository at this point in the history
  • Loading branch information
rockspore committed Nov 6, 2023
1 parent 10f1c67 commit 57e8209
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core/tsi/ssl_transport_security.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,10 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX* ctx, int is_client,
if (is_client) {
int ssl_result;
SSL_set_connect_state(ssl);
if (server_name_indication != nullptr) {
// Skip if the SNI looks like an IP address because IP addressed are not
// allowed as host names.
if (server_name_indication != nullptr &&
!looks_like_ip_address(server_name_indication)) {
if (!SSL_set_tlsext_host_name(ssl, server_name_indication)) {
gpr_log(GPR_ERROR, "Invalid server name indication %s.",
server_name_indication);
Expand Down Expand Up @@ -1831,10 +1834,8 @@ tsi_result tsi_ssl_client_handshaker_factory_create_handshaker(
const char* server_name_indication, size_t network_bio_buf_size,
size_t ssl_bio_buf_size, tsi_handshaker** handshaker) {
return create_tsi_ssl_handshaker(
factory->ssl_context, 1,
looks_like_ip_address(server_name_indication) ? nullptr
: server_name_indication,
network_bio_buf_size, ssl_bio_buf_size, &factory->base, handshaker);
factory->ssl_context, 1, server_name_indication, network_bio_buf_size,
ssl_bio_buf_size, &factory->base, handshaker);
}

void tsi_ssl_client_handshaker_factory_unref(
Expand Down

0 comments on commit 57e8209

Please sign in to comment.