Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2-client fatally fails with IP address URLs #70

Open
lanurmi opened this issue Sep 8, 2021 · 1 comment
Open

http2-client fatally fails with IP address URLs #70

lanurmi opened this issue Sep 8, 2021 · 1 comment

Comments

@lanurmi
Copy link

lanurmi commented Sep 8, 2021

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

  1. 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

61a502f

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

@Lukasa
Copy link
Contributor

Lukasa commented Sep 8, 2021

SNI must be disabled altogether if you're using an IP address as your hostname, because you may not send an IP address in SNI. What should happen here is we should either allow you to express a hostname parameter in that case (to override the IP address) or we should explicitly set it to nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants