Don't use IP addresses for SNI
This patch was authored by @olivernyc and released by @0xTim.
TLS forbids the use of literal IPv4 and IPv6 addresses in server name indication. However, websocket-kit passes IP addresses to NIOSSLClientHandler
as serverHostname
, which triggers an error when the underlying validateSNIServerName
is called. See apple/swift-nio-ssl#380 for more context.
This PR adds a do / catch statement to pass nil
for serverHostname
in case of the specific cannotUseIPAddressInSNI
error, which allows for secure connections to IP addresses.