Skip to content

Commit 39d98e1

Browse files
committed
Copy peer hostname from sockaddr_union_struct into tcp_connection
This is so that hostnames in TLS certificates can be validated.
1 parent e91311e commit 39d98e1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

net/net_tcp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,11 @@ struct tcp_connection* tcp_conn_create(int sock, struct sockaddr_union_struct* s
958958
return NULL;
959959
}
960960

961+
/* copy peer hostname into the tcp_connection so that tls_openssl can verify
962+
* the certificate hostname */
963+
strncpy(c->hostname, su->hostname, sizeof(c->hostname)-1);
964+
c->hostname[sizeof(c->hostname)-1] = 0;
965+
961966
if (protos[c->type].net.conn_init &&
962967
protos[c->type].net.conn_init(c) < 0) {
963968
LM_ERR("failed to do proto %d specific init for conn %p\n",

net/tcp_conn_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ struct tcp_connection{
182182
struct tcp_async_data *async;
183183
/* protocol specific data attached to this connection */
184184
void *proto_data;
185+
char hostname[256]; /* remote side hostname (used for TLS certificate hostname verification) */
185186
};
186187

187188

0 commit comments

Comments
 (0)