Skip to content

Commit bdfaaa5

Browse files
authored
Merge pull request #2 from dariopellegrino00/ssl-host-name
Set SNI hostname TLS handshake failures
2 parents 450133d + 0dd20a7 commit bdfaaa5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

libwsc/WebSocketClient.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,16 @@ void WebSocketClient::connect() {
119119

120120
ssl = SSL_new(ctx);
121121

122+
122123
if (!ssl) {
123124
SSL_CTX_free(ctx);
124125
log_error("SSL_new() failed");
125126
sendError(ErrorCode::TLS_INIT_FAILED, "SSL context creation failed");
126127
return;
127128
}
128129

130+
SSL_set_tlsext_host_name(ssl, host.c_str());
131+
129132
if (!tlsOptions.disableHostnameValidation) {
130133
X509_VERIFY_PARAM* param = SSL_get0_param(ssl);
131134
if (param) {
@@ -2089,4 +2092,4 @@ std::string WebSocketClient::computeAccept(const std::string &key) {
20892092
auto rawDigest = hexToBytes(hexDigest);
20902093
return base64_encode(rawDigest.data(), rawDigest.size());
20912094
#endif
2092-
}
2095+
}

0 commit comments

Comments
 (0)