Skip to content

Commit f937a51

Browse files
committed
Extend SNI support for mqtt, websockets and raw tls
1 parent 547ed87 commit f937a51

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

app/modules/mqtt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ static sint8 mqtt_socket_do_connect(struct lmqtt_userdata *mud)
989989
if(mud->conf.flags.secure)
990990
{
991991
NODE_DBG("mqtt_socket_do_connect using espconn_secure\n");
992+
992993
espconn_status = espconn_secure_connect(&mud->pesp_conn);
993994
}
994995
else
@@ -1020,6 +1021,13 @@ static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
10201021
NODE_DBG("socket_dns_found success: ");
10211022
NODE_DBG(IPSTR, IP2STR(&(ipaddr->addr)));
10221023
NODE_DBG("\n");
1024+
#ifdef CLIENT_SSL_ENABLE
1025+
if(mud->conf.flags.secure)
1026+
{
1027+
NODE_DBG("socket_dns_found configuring hostname for SNI\n");
1028+
espconn_secure_set_hostname( name );
1029+
}
1030+
#endif
10231031

10241032
if(mqtt_socket_do_connect(mud) != ESPCONN_OK) {
10251033
NODE_DBG("socket_dns_found, got DNS but connect failed\n");

app/modules/tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ static void tls_socket_dns_cb( const char* domain, const ip_addr_t *ip_addr, tls
174174
lua_gc(L, LUA_GCRESTART, 0);
175175
} else {
176176
os_memcpy(ud->pesp_conn.proto.tcp->remote_ip, &addr.addr, 4);
177+
espconn_secure_set_hostname( domain );
177178
espconn_secure_connect(&ud->pesp_conn);
178179
}
179180
}
@@ -204,7 +205,6 @@ static int tls_socket_connect( lua_State *L ) {
204205
ud->pesp_conn.proto.tcp->remote_port = port;
205206

206207
espconn_secure_set_hostname(domain);
207-
208208
espconn_regist_connectcb(&ud->pesp_conn, (espconn_connect_callback)tls_socket_onconnect);
209209
espconn_regist_disconcb(&ud->pesp_conn, (espconn_connect_callback)tls_socket_ondisconnect);
210210
espconn_regist_reconcb(&ud->pesp_conn, (espconn_reconnect_callback)tls_socket_onreconnect);

app/websocket/websocketclient.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ static void dns_callback(const char *hostname, ip_addr_t *addr, void *arg) {
712712

713713
if (ws->isSecure) {
714714
NODE_DBG("secure connecting \n");
715+
espconn_secure_set_hostname( hostname );
715716
espconn_secure_connect(conn);
716717
}
717718
else {

0 commit comments

Comments
 (0)