-
Notifications
You must be signed in to change notification settings - Fork 117
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
Allow DNS override #675
Allow DNS override #675
Conversation
Sometimes it can be useful to connect to one host e.g. `x.example.com` but request and validate the certificate chain as if we would connect to `y.example.com`. This is what this PR adds support for by adding a `dnsOverride` configuration to `HTTPClient.Configuration`. This is similar to curls `—resolve-to` option but only allows overriding host and not ports for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks really good! One small note.
@@ -434,7 +434,7 @@ extension HTTPConnectionPool.ConnectionFactory { | |||
} | |||
#endif | |||
|
|||
let sslServerHostname = self.key.connectionTarget.sslServerHostname | |||
let sslServerHostname = self.key.serverNameIndicatorOverride ?? self.key.connectionTarget.sslServerHostname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we hide this in a computed property on the key so as to centralise the knowledge of how to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Actually found through this another place where I forgot to use the override, namely if we proxy:
f296aa4
Sometimes it can be useful to connect to one host e.g.
x.example.com
but request and validate the certificate chain as if we would connect toy.example.com
. This is what this PR adds support for by adding adnsOverride
configuration toHTTPClient.Configuration
. This is similar to curls—resolve
option but only allows overriding host and not ports for now.