Skip to content

Commit b586f7d

Browse files
committed
tlshd: Reverse DNS lookup of peername
If the peername happens to be an IP address, it needs to be converted to a domain name before using it for Server Name Identification. Signed-off-by: Chuck Lever <[email protected]>
1 parent 7655d96 commit b586f7d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tlshd/netlink.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,21 @@ static int tlshd_genl_valid_handler(struct nl_msg *msg, void *arg)
257257
tlshd_parse_peer_identity(parms, tb[HANDSHAKE_A_ACCEPT_PEER_IDENTITY]);
258258
tlshd_parse_certificate(parms, tb[HANDSHAKE_A_ACCEPT_CERTIFICATE]);
259259

260+
/* SNI needs a domain name. If the kernel provided an IP
261+
* address, just use the reverse lookup results below. */
262+
if (peername) {
263+
static const struct addrinfo hints = {
264+
.ai_family = AF_UNSPEC,
265+
.ai_flags = AI_NUMERICHOST,
266+
};
267+
struct addrinfo *res;
268+
269+
err = getaddrinfo(peername, NULL, &hints, &res);
270+
if (!err) {
271+
freeaddrinfo(res);
272+
peername = NULL;
273+
}
274+
}
260275
if (peername)
261276
strcpy(tlshd_peername, peername);
262277
else {

0 commit comments

Comments
 (0)