feat: load every certificate in the rotating keys engine ca-cert-file - #3528
Open
pjfanning wants to merge 1 commit into
Open
feat: load every certificate in the rotating keys engine ca-cert-file#3528pjfanning wants to merge 1 commit into
pjfanning wants to merge 1 commit into
Conversation
Motivation: `RotatingKeysSSLEngineProvider` read `ca-cert-file` with `CertificateFactory.generateCertificate`, which stops at the first PEM block. A CA file that bundles more than one certificate - a root plus the intermediates it delegates to, or two roots while a CA is being rotated - was therefore only half trusted, and peers presenting a certificate from any of the other CAs in the bundle were rejected. Modification: Add `PemManagersProvider.loadCertificates`, which uses `generateCertificates` and closes the stream. `buildTrustManagers` and `buildKeyManagers` now take the whole `Seq[Certificate]`; every CA certificate is stored under its own alias so all of them become trust anchors. The chain attached to the key entry is built by walking issuer -> subject from the node certificate upwards, so CA certificates that did not issue it are trusted without being sent to the peer; when none of them matches the issuer the previous behaviour (all of them) is kept. `readFiles` now fails with `SslTransportException` when the CA file yields no certificate at all, instead of passing a null certificate on. Result: `ca-cert-file` may bundle any number of certificates and all of them are trusted. Single-certificate configurations behave as before. Tests: - sbt "remote/testOnly org.apache.pekko.remote.artery.tcp.ssl.PemManagersProviderSpec org.apache.pekko.remote.artery.tcp.ssl.TlsResourcesSpec org.apache.pekko.remote.artery.tcp.ssl.*Rotating*" - passed - sbt "remote/mimaReportBinaryIssues" - passed - both were run before this change was merged with the keystore-password change on main; verification of the merged state is left to CI References: None - follow-up on multi-certificate `ca-cert-file` support
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.
Motivation
RotatingKeysSSLEngineProviderreadsca-cert-filewithCertificateFactory.generateCertificate, which stops at the first PEM block. A CA file that bundles more than one certificate — a root plus the intermediates it delegates to, or two roots while a CA is being rotated — was therefore only half trusted, and peers presenting a certificate issued by any of the other CAs in the bundle were rejected.Modification
PemManagersProvider.loadCertificates, which usesgenerateCertificatesand closes the stream (the singularloadCertificatenever did).buildTrustManagersandbuildKeyManagerstake the wholeSeq[Certificate]; every CA certificate is stored under its own alias, so all of them become trust anchors.readFilesfails withSslTransportExceptionwhen the CA file yields no certificate, instead of passing a null certificate on.ca-cert-fileinreference.conf.Result
ca-cert-filemay bundle any number of certificates and all of them are trusted. Single-certificate configurations behave exactly as before.Tests
sbt "remote/testOnly org.apache.pekko.remote.artery.tcp.ssl.PemManagersProviderSpec org.apache.pekko.remote.artery.tcp.ssl.TlsResourcesSpec org.apache.pekko.remote.artery.tcp.ssl.*Rotating*"— passedsbt "remote/mimaReportBinaryIssues"— passedkeystore-passwordchange onmain; verification of the merged state is left to CI.PemManagersProviderSpec, backed by a newssl/exampleca-bundle.crtresource (exampleca.crt+pem/selfsigned-certificate.pem): the trust manager's accepted issuers contain both certificates, and the key manager's chain for the node certificate contains only the CA that issued it.References
None — follow-up on multi-certificate
ca-cert-filesupport