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

fix: can't resolve ip address with square brackets #182

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

digitwolf
Copy link

Problem:
Sending to destination like https://[::1]/ fails with error invalid dnsname. Error is thrown here https://github.com/rustls/hyper-rustls/blob/main/src/connector.rs#L95

hyper-rustls resolves the Hostname as hyper::Uri::host This makes hostname = "[::1]" which is HTTP-specific form of writing IPv6 address.

Solution:
Since square brakets are coming from hyper and not part standard IP notation we remove any square brakets inside of the connector before calling the rustls::ServerName::try_from(hostname)

src/connector.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/connector.rs Outdated Show resolved Hide resolved
Problem:
Sending to destination like https://[::1]/ fails with error invalid dnsname.
Error is thrown here https://github.com/rustls/hyper-rustls/blob/main/src/connector.rs#L95

hyper-rustls resolves the Hostname as hyper::Uri::host
This makes hostname = "[::1]" which is HTTP-specific form of writing IPv6 address.

Solution:
Since square brakets are coming from hyper and not part standard IP notation
we remove any square brakets inside of the connector before calling
the rustls::ServerName::try_from(hostname)
@digitwolf digitwolf closed this Dec 6, 2022
@digitwolf digitwolf reopened this Dec 6, 2022
@digitwolf
Copy link
Author

djc, I think I hit the wrong button, please approve the workflow again

@djc djc merged commit 0a34dd9 into rustls:main Dec 7, 2022
@djc
Copy link
Member

djc commented Dec 7, 2022

Okay, thanks!

@digitwolf
Copy link
Author

Thank you for merging djc!
Could you publish it to cargo too?

@djc djc mentioned this pull request Dec 8, 2022
5 tasks
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

Successfully merging this pull request may close these issues.

None yet

3 participants