Postgres custom root certificates #3366
Draft
+1,549
−18
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.
Partially fixes fermyon/feedback#64 - this handles the custom root certs side, but not the
sslmode=verify-fullpart.Credit and thanks to @kate-goldenring for figuring out a test case.
How to specify custom roots
In this PR, trusted roots certificates are referenced in the runtime config file:
Things to consider:
This leaves no trace in the manifest that an application might require custom certificates: deployment tools therefore have no way of knowing that they need to also prepare custom certs. (Although this is probably reasonable. The deployment environment will likely connect to a different Postgres host, which may or may not require a custom CA when accessed from the deployment environment.)
This makes it clear that the custom certificates will only be when making Postgres connections. But this seems potentially weird: if I trust these CAs, why would I not trust them for all my network traffic? But I am not sure how to set this up. Sockets have some existing runtime-config network config stuff but it's not clear to me whether that applies to Postgres (e.g. I don't think the Postgres library allows for client certificates) and if so how to re-use it. But very open to feedback on this: it feels like trust is trust and would be good not to have that partitioned by API.
Testing
I don't currently have a good way to test this. Kate wrote an excellent and convenient manual test case, which I've committed as part of this draft, but really we'd want a Docker-based test to run as part of integration. The existing PG tests are done via conformance-test, but that doesn't seem like a natural home for this (not to mention I'd prefer not to have to deal with the circularity problem again), and yet I'm hazy on how to write PG tests outside of conformance-test. So... open to advice/suggestions on this.