feat: Allow users to specify a prebuilt 'rustls' configuration for TLS #4051
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Does your PR solve an issue?
Closes #4049.
Is this a breaking change?
No.
There is a breaking change for
sqlx-core
, but that's considered semver-exempt.Open Design questions
What should the interaction be between
sslmode
and a prebuiltrustls
configuration?In the current PR, if TLS is available, we behave as if the user specified
PgSslMode::VerifyFull
.rustls::client::ClientConfig
doesn't expose the underlying server cert verifier, therefore it's not possible to wrap around it to disable hostname verification or cert verification.At the same time, I think it'd be surprising for a user that specified its own
rustls
configuration to get the kind of permissive behaviour thatPgSslMode::Prefer
implies.Conversion into a URL is inevitably lossy
We can't convert a prebuilt
rustls
client configuration into the three URL parameters thatlibpq
supports.At the moment, the PR ends up building a URL that doesn't have
ssl*
parameters. Would it be preferable to fail the conversion entirely?Follow-up work
If we agree on the approach, I can add prebuilt
rustls
support to MySQL; either in this PR or in a separate one.