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

wss fails on IPV6 address #1224

Closed
nmset opened this issue Mar 19, 2020 · 6 comments · Fixed by #1266
Closed

wss fails on IPV6 address #1224

nmset opened this issue Mar 19, 2020 · 6 comments · Fixed by #1266

Comments

@nmset
Copy link

nmset commented Mar 19, 2020

wss fails to work on IPV6 addresses. No problem is seen with IPV4 addresses and with wss://localhost:port.

The attached file demonstrates this issue on Linux.

tls or tls+tcp just works in the attached file.

Please advise if wss is expected to work with IPV6 addresses.

Regards.

nng_wss_ipv6_c.cpp.txt

@gdamore
Copy link
Contributor

gdamore commented Mar 28, 2020

That should have worked, but tbh I have not really tested for it, and I suspect you've identified a bug.

@gdamore
Copy link
Contributor

gdamore commented Mar 29, 2020

Actually, looking in more detail, I expect your use of TLS may be at issue.

Using IP addresses for TLS will generally not work, unless your certificate explicitly lists those IP addresses. You can test this by changing the auth mode on the client from NNG_TLS_AUTH_MODE_REQUIRED to NNG_TLS_AUTH_MODE_NONE.

If that "Just Works", then try changing your certificate.

Having said that, it may be possible that we can do a lookup on the host name and see if it resolves to the given IPv6 address.

I'm going to hold this bug issue open pending feedback.

@gdamore
Copy link
Contributor

gdamore commented Mar 29, 2020

It's also entirely possible that the TLS library you are using (probably mbedTLS unless you went out of your want to configure wolfSSL in 1.3.0) may not honor the IPv6 address validation.

@nmset
Copy link
Author

nmset commented Mar 29, 2020

I tested with NNG_TLS_AUTH_MODE_NONE to no avail.

Then with both NNG_TLS_AUTH_MODE_NONE and NNG_TLS_AUTH_MODE_REQUIRED, I tried changing the cert common name to ::1, [::1] and [::1]:8000. No better luck.

I'm indeed using mbedTLS.

Using IP addresses for TLS will generally not work

I must precise that tls+tcp://[IP::v6]:port does work.

Thanks for looking into that.

@gdamore
Copy link
Contributor

gdamore commented Mar 29, 2020

Ok this is good information. I will write a test case to cover this and make sure to get a fix before too long. I am spread a little thin at the moment so it might be a week or so.

@gdamore gdamore self-assigned this May 24, 2020
@gdamore
Copy link
Contributor

gdamore commented Jul 26, 2020

This looks like it is not specific to wss, but to websocket in general.

Specifically it looks like what is happening is that the method lookup is not working -- I think this is actually a bug in the HTTP server framework.

gdamore added a commit that referenced this issue Jul 26, 2020
fixes #1224 wss fails on IPV6 address

This fixes bugs and inconsistencies in the way addresses are
handled for HTTP (and consequently websocket).  The Host:
address line needs to look at numeric IPs and treat wildcards
as if they are not specified, and needs to understand the IPv6
address format using brackets (e.g. [::1]:80).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants