Skip to contentSkip to conversation

server: Add boolean config option "verify_peeraddr" under "[authenticate.server]".

PATCH In review Ken Milmore 1 participant 1 message Jun 8, 2025 Handshake upcall for transport layer security

lore
Share & tools
lore
#0 lore raw

PATCH 6/7 server: Add boolean config option "verify_peeraddr" under "[authenticate.server]".

If this option is set to true, then the server will pass the textualized client IP/IPv6 address to GnuTLS to be verified against the client certificate. This is intended to allow the server to verify client certificates which include an IP/IPv6 address as a Subject Alternative Name.

If this option is set together with the "verify_peername" option, then a forward-confirmed hostname will be used for the client if one can be found, with the IP address being used as a fallback rather than rejecting the certificate.

---
 src/tlshd/config.c | 2 ++
 src/tlshd/server.c | 8 ++++++++
 src/tlshd/tlshd.h  | 1 +
 3 files changed, 11 insertions(+)
src/tlshd/config.c +2 -0
index c647681..9599e1b 100644
@@ -94,6 +94,8 @@ bool tlshd_config_init(const gchar *pathname)
 
 	tlshd_server_verify_peername = g_key_file_get_string(tlshd_configuration,
 					"authenticate.server", "verify_peername", NULL);
+	tlshd_server_verify_peeraddr = g_key_file_get_string(tlshd_configuration,
+					"authenticate.server", "verify_peeraddr", NULL);
 
 	keyrings = g_key_file_get_string_list(tlshd_configuration,
 					      "authenticate",
src/tlshd/server.c +8 -0
index 4a47fe8..2043f23 100644
@@ -44,6 +44,7 @@
 #include "netlink.h"
 
 bool tlshd_server_verify_peername = false;
+bool tlshd_server_verify_peeraddr = false;
 
 static gnutls_privkey_t tlshd_server_privkey;
 static unsigned int tlshd_server_certs_len = TLSHD_MAX_CERTS;
@@ -154,10 +155,17 @@ static bool tlshd_server_get_verify_hostname(struct tlshd_handshake_parms *parms
 			tlshd_log_debug("server: Verify forward-confirmed peer name '%s'",
 					parms->peername);
 			hostname = parms->peername;
+		} else if (tlshd_server_verify_peeraddr) {
+			tlshd_log_debug("server: Peer name unconfirmed: Verify peer address '%s'",
+					parms->peeraddr_txt);
+			hostname = parms->peeraddr_txt;
 		} else {
 			tlshd_log_debug("server: Peer name unconfirmed: Forcing error.");
 			verify_hostname = false;
 		}
+	} else if (tlshd_server_verify_peeraddr) {
+		tlshd_log_debug("server: Verify peer address '%s' per configuration.");
+		hostname = parms->peeraddr_txt;
 	}
 
 	*hostname_p = hostname;
src/tlshd/tlshd.h +1 -0
index 9e5b221..d0602bf 100644
@@ -25,6 +25,7 @@ extern int tlshd_tls_debug;
 extern unsigned int tlshd_delay_done;
 extern int tlshd_stderr;
 extern bool tlshd_server_verify_peername;
+extern bool tlshd_server_verify_peeraddr;
 
 struct nl_sock;
 
Signature · 1 line
2.47.2