Skip to content

Commit e5acf5a

Browse files
committed
verify_peer_identity: Do not pass the resolve flag to validate_hostname()
When acting as a relay (client), the certificate of the server we are connecting to must match either the DNS name or IP address we used. The names in the server's cert should be treated as untrusted and not be resolved to IP addresses for matching. This matches the existing behavior of the sudoers log client. Thanks to Joshua Rogers for finding this.
1 parent 2f4e05d commit e5acf5a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

logsrvd/tls_client.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
#if defined(HAVE_OPENSSL)
5454

5555
/*
56-
* Check that the server's certificate is valid that it contains the
57-
* server name or IP address.
56+
* Check that the server's certificate is valid and that it
57+
* contains the server name or IP address.
5858
* Returns 0 if the cert is invalid, else 1.
5959
*/
6060
static int
@@ -95,13 +95,8 @@ verify_peer_identity(int preverify_ok, X509_STORE_CTX *ctx)
9595
ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
9696
peer_info = SSL_get_ex_data(ssl, 1);
9797

98-
/*
99-
* Validate the cert based on the host name and IP address.
100-
* If host name is not known, validate_hostname() can resolve it.
101-
*/
102-
result = validate_hostname(peer_cert,
103-
peer_info->name ? peer_info->name : peer_info->ipaddr,
104-
peer_info->ipaddr, peer_info->name ? 0 : 1);
98+
/* Validate the cert based on the host name and IP address. */
99+
result = validate_hostname(peer_cert, peer_info->name, peer_info->ipaddr, 0);
105100

106101
debug_return_int(result == MatchFound);
107102
}

0 commit comments

Comments
 (0)