tcptls/iostream: Add support for setting SNI on client TLS connections

If the hostname field of the ast_tcptls_session_args structure is
set (which it is for websocket client connections), that hostname
will now automatically be used in an SNI TLS extension in the client
hello.

Resolves: #713

UserNote: Secure websocket client connections now send SNI in
the TLS client hello.

(cherry picked from commit 9e1a6fa0a7)
This commit is contained in:
George Joseph
2024-04-23 14:15:20 -06:00
committed by Asterisk Development Team
parent 824b4ce855
commit c9439c8ad7
3 changed files with 39 additions and 5 deletions

View File

@@ -741,6 +741,13 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
/* Set current info */
ast_sockaddr_copy(&desc->old_address, &desc->remote_address);
if (!ast_strlen_zero(desc->hostname)) {
if (ast_iostream_set_sni_hostname(tcptls_session->stream, desc->hostname) != 0) {
ast_log(LOG_WARNING, "Unable to set SNI hostname '%s' on connection '%s'\n",
desc->hostname, desc->name);
}
}
return tcptls_session;
error: