tls-util: Fix ssl_root_cert to load all certs from PEM bundles#35487
Merged
def- merged 1 commit intoMaterializeInc:mainfrom Mar 20, 2026
Merged
tls-util: Fix ssl_root_cert to load all certs from PEM bundles#35487def- merged 1 commit intoMaterializeInc:mainfrom
def- merged 1 commit intoMaterializeInc:mainfrom
Conversation
`X509::from_pem` only reads the first certificate from a PEM bundle, so if `ssl_root_cert` contains multiple CA certificates (e.g., root + intermediates or multiple roots), only the first is loaded into the trust store. This causes TLS verification to fail with "unknown ca" when the relevant trust anchor is not the first cert in the bundle, diverging from libpq behavior which accepts CA bundles. Fix by using `X509::stack_from_pem` (which parses all certs) and adding each to the cert store, mirroring the pattern already used in `pkcs12der_from_pem` in the same file. Bug introduced in PR MaterializeInc#13552 (commit fb6244a) which changed from file-based `set_ca_file()` to in-memory `add_cert(X509::from_pem())`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for opening this PR! Here are a few tips to help make the review process smooth for everyone. PR title guidelines
Pre-merge checklist
|
Contributor
Author
|
Ready for review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
X509::from_pemonly reads the first certificate from a PEM bundle, so ifssl_root_certcontains multiple CA certificates (e.g., root + intermediates or multiple roots), only the first is loaded into the trust store. This causes TLS verification to fail with "unknown ca" when the relevant trust anchor is not the first cert in the bundle, diverging from libpq behavior which accepts CA bundles.Fix by using
X509::stack_from_pem(which parses all certs) and adding each to the cert store, mirroring the pattern already used inpkcs12der_from_pemin the same file.Bug introduced in PR #13552 which changed from file-based
set_ca_file()to in-memoryadd_cert(X509::from_pem()).