-
-
Notifications
You must be signed in to change notification settings - Fork 82
Explicit TLS config #237
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
Explicit TLS config #237
Conversation
Codecov Report
@@ Coverage Diff @@
## main #237 +/- ##
==========================================
+ Coverage 39.82% 44.04% +4.21%
==========================================
Files 116 116
Lines 9413 9474 +61
==========================================
+ Hits 3749 4173 +424
+ Misses 5664 5301 -363
Flags with carried forward coverage won't be shown. Click here to find out more.
|
struct TLS { | ||
enum Base { | ||
case disable | ||
case prefer(NIOSSLContext) | ||
case require(NIOSSLContext) | ||
} | ||
|
||
var base: Base | ||
|
||
private init(_ base: Base) { | ||
self.base = base | ||
} | ||
|
||
static var disable: Self = Self.init(.disable) | ||
|
||
static func prefer(_ sslContext: NIOSSLContext) -> Self { | ||
self.init(.prefer(sslContext)) | ||
} | ||
|
||
static func require(_ sslContext: NIOSSLContext) -> Self { | ||
self.init(.require(sslContext)) | ||
} | ||
} |
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.
@gwynne This will become public API eventually.
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.
LGTM
Motivation
Currently users provide a TLSConfiguration to the PSQLConnection.Configuration to signal they want to require TLS. This is very implicit and it will create a new
NIOSSLContext
for every new connection (VERY, VERY expensive operation).Changes
PSQLConnection.Configuration
. The initial provided values are.disable
,.prefer
,.require
.prefer
or.require
they must provide a NIOSSLContextResult