Merge the SSLClient and WebSocketClient TLS session setup

SSLClient::initialize_ssl kept its own copy of the session setup that
detail::setup_client_tls_session already implemented for WebSocketClient.
Extend the shared function with the pieces only SSLClient needed - a session
verifier, an independent hostname verification flag, the context mutex,
Windows Schannel verification and error details - and let initialize_ssl
build a ClientTlsSessionOptions and call it. All of them default, so
WebSocketClient's call site is unchanged.

This settles one difference between the two: WebSocketClient used to call
tls::set_hostname for named hosts, which on OpenSSL turns on verification
during the handshake, while SSLClient always set SNI only and verified
post-handshake. The shared function now does the latter for both, so
tls::set_hostname loses its last caller and goes away, as does the
write-only SSLClient::verify_result_.

Certificate verification with a host name rather than an IP literal was the
one combination the WebSocket tests never covered, and it is exactly the
path this normalizes. WebSocketSSLDnsHostTest fills that in; cert2 gains a
DNS:localhost SAN so a name can be verified against it.
This commit is contained in:
yhirose
2026-08-07 13:21:37 -04:00
parent 98be5fd3a6
commit 1c2607cbb8
3 changed files with 231 additions and 185 deletions

View File

@@ -18,4 +18,4 @@ emailAddress = test@email.address
challengePassword = 1234
[SAN]
subjectAltName=IP:127.0.0.1
subjectAltName=IP:127.0.0.1,DNS:localhost