Skip to content

Commit 06ded3a

Browse files
committed
SRV lookups: take hostname from original lookup instead of SRV record
This is so that TLS certificate validation looks at the correct hostname instead of the one in the SRV record.
1 parent 37432cc commit 06ded3a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

resolve.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,18 @@ struct hostent* sip_resolvehost( str* name, unsigned short* port,
18811881
}
18821882

18831883
he = do_srv_lookup( tmp, port, dn);
1884-
if (he)
1884+
if (he) {
1885+
/* we need to check TLS certificates against the original requested
1886+
* hostname, not the name from the SRV record */
1887+
if (name->len >= MAX_DNS_NAME) {
1888+
LM_ERR("domain name too long\n");
1889+
return 0;
1890+
}
1891+
memcpy(tmp, name->s, name->len);
1892+
tmp[name->len] = '\0';
1893+
he->h_name = tmp;
18851894
return he;
1895+
}
18861896

18871897
LM_DBG("no valid SRV record found for %s, trying A record lookup...\n",
18881898
tmp);

0 commit comments

Comments
 (0)