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

Connect to IP but send a user-specified hostname in the SNI field [was: Do we have feature like curl's --resolve option?] #115

Open
nixzhu opened this issue Oct 10, 2019 · 10 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@nixzhu
Copy link

nixzhu commented Oct 10, 2019

With curl's --resolve option, it should supports IP based SNI.
Ref https://curl.haxx.se/docs/manpage.html#--resolve

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 10, 2019

By "IP-based SNI" I assume what you mean is "I want to connect to a specific IP address but send a hostname in the SNI field". In which case: yes, we could plausibly support that use-case.

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 10, 2019

However, I should stress that we don't support it today so far as I know. All the building blocks are there in NIO though.

@nixzhu
Copy link
Author

nixzhu commented Oct 10, 2019

Thanks!

@nixzhu nixzhu closed this as completed Oct 10, 2019
@weissi
Copy link
Contributor

weissi commented Oct 10, 2019

@nixzhu sure you want to close this issue? We could keep at as a feature request for async-http-client. If you'd like to give it a shot you might even want to try writing a patch? We're here to help :)

@nixzhu
Copy link
Author

nixzhu commented Oct 10, 2019

@weissi I like it becomes a feature request, but I'm not capable for the implementation for now.

@nixzhu nixzhu reopened this Oct 10, 2019
@weissi weissi changed the title Do we have feature like curl's --resolve option? Connect to IP but send a user-specified hostname in the SNI field [was: Do we have feature like curl's --resolve option?] Oct 10, 2019
@weissi weissi added the enhancement New feature or request label Oct 10, 2019
@weissi weissi added the good first issue Good for newcomers label Feb 26, 2020
@weissi
Copy link
Contributor

weissi commented Feb 26, 2020

This shouldn't be too hard to implement. The line that needs changing is this one:

try NIOSSLClientHandler(context: context, serverHostname: key.host.isIPAddress ? nil : key.host),

in HTTPClient.swift. Currently, this does:

If key.host is a hostname, then use it, if it's an IP address, don't send any SNI hostname.

In the future, this should check if we have an SNI hostname override in our configuration, if yes: use the override, if no: do the old logic.

If you feel like giving the implementation a go and have any questions, please reach out :)

@shekhar-rajak
Copy link

I want to work on this issue.

if we have an SNI hostname override in our configuration,

So we should have SNI hostname attribute in HTTPClient.configuration or in tlsConfiguration ?

@weissi
Copy link
Contributor

weissi commented Feb 27, 2020

@shekhar-rajak probably HTTPClient.configuration because one tlsConfiguration can be used for multiple clients. Possibly even on Request because I'd assume you don't want to override all SNI hostnames for all requests. I'd expect this to be a per-request thing

@dellgreen
Copy link

this would be extremely useful for us also

@weissi
Copy link
Contributor

weissi commented Dec 16, 2021

@dellgreen would you be up to taking a stab at the implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants