-
Notifications
You must be signed in to change notification settings - Fork 123
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
Support request specific TLS configuration #358
Conversation
Can one of the admins verify this patch? |
5 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@swift-server-bot add to allowlist |
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.
Fab, thank you! This looks like a great start!
I left a few comments, mostly requesting changes that we don't accidentally merge the branch dependency.
@@ -139,12 +139,16 @@ final class ConnectionPool { | |||
self.port = request.port | |||
self.host = request.host | |||
self.unixPath = request.socketPath | |||
if let tls = request.tlsConfiguration { |
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.
@artemredkin should we add a test case that targets the pool directly here? Ie no actual connections?
@madsodgaard hmm, weird 5.0 compiler warning (that we turn into errors):
Also, async-http-client uses automatic format checking with SwiftFormat. If you run SwiftFormat over the source, then the "soundness" part should pass. |
@weissi Whoops, forgot a return statement 😅 |
@madsodgaard also the API breakage checker detected an API breakage:
Note that in Swift you cannot just add a new parameter (even if it has a default value) without breaking API. Instead of adding the |
Sources/AsyncHTTPClient/BestEffortHashableTLSConfiguration.swift
Outdated
Show resolved
Hide resolved
Sources/AsyncHTTPClient/Utils.swift
Outdated
@@ -150,17 +150,22 @@ extension NIOClientTCPBootstrap { | |||
let key = destination | |||
|
|||
let requiresTLS = key.scheme.requiresTLS | |||
// Override optional connection pool configuration. | |||
var keyConfiguration = configuration |
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.
I'm finding the naming here somewhat confusing: keyConfiguration is not derived from the key but from configuration
, and then we override it with the TLS configuration from key
.
I think it'd be nice to wrap this logic up into something written as a function that clarifies what it does (merges config from two sources, preferring config in the key
to the general configuration.
I'm also a bit uncertain as to why this is necessary. Why isn't configuration
already carrying this TLS config?
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.
Also, should this merge perhaps be done at a higher level, say when we create the HTTP1ConnectionProvider
? I am a bit nervous about having two separate configs from the perspective of the connection provider: it should always be creating the exact same connection each time.
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.
configuration
is specific for the entire HTTPClient
, so atm it passes down the configuration of client through all these methods. So, we need at some point to override the tlsConfiguration
of it.
I moved the actual configuration "generation" to the place where we initialize the connection provider as you suggested, and added config(overriding:)
to Key
to retrieve key-specific configuration. Let me know, if this is better!
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.
Cool, this LGTM.
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.
Fantastic, thank you very much!
Adds support for request-specific TLS configuration:
Request(url: "https://webserver.com", tlsConfiguration: .forClient())
apple/swift-nio-ssl#280 must be released, before this can be merged.