-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Passing a URL with an IP address as an argument to http2-client
results in a fatal error, because creating NIOSSLClientHandler
is assumed never to fail.
Yes, I know this can be worked around by passing serverHostname: nil
to the NIOSSLClientHandler
constructor, but then SNI will be disabled altogether.
Even if URLs with IP addresses are not a typical use case with HTTPS, I think this example code should set an example on what to do with IP addresses, and not just crash.
Expected behavior
Error about failing to verify certificate, but no fatal error.
Actual behavior
Fatal error: 'try!' expression unexpectedly raised an error: NIOSSLExtraError.cannotUseIPAddressInSNI: IP addresses cannot validly be used for Server Name Indication, got 192.168.0.1: file http2_client/main.swift, line 305
zsh: illegal hardware instruction swift run http2-client https://192.168.0.1/
Steps to reproduce
- Run
% swift run http2-client https://192.168.0.1/
(doesn't matter if there's a server running at that IP or not)
If possible, minimal yet complete reproducer code (or URL to code)
[anything to help us reproducing the issue]
version/commit hashes from all involved dependencies
Swift & OS version (output of swift --version && uname -a
)
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Darwin MiniII.lan 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 22 19:49:55 PDT 2021; root:xnu-6153.141.35~1/RELEASE_X86_64 x86_64