Repository navigation
Fix #1397: use the JVM default trust and key manager algorithms - #1690
Merged
Merged
Conversation
DefaultSslContextFactory defaulted to the obsolete SunX509 algorithm for both the trust manager and the key manager. The SunX509 trust manager rejects a valid certificate chain that is not in order with "Certificate chaining error", whereas the JVM default (PKIX) accepts it. The defaults are now TrustManagerFactory.getDefaultAlgorithm() and KeyManagerFactory.getDefaultAlgorithm(). The system properties, the trustManagerAlgorithm and keyManagerAlgorithm parameters and the setters still take precedence, so SunX509 can still be selected explicitly. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 23, 2026
|
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.




Fixes #1397.
Problem
DefaultSslContextFactorydefaulted to the obsoleteSunX509algorithm for both the trust manager and the key manager. TheSunX509trust manager rejects a valid certificate chain that is not in order withValidatorException: Certificate chaining error, whereas the JVM default (PKIX) accepts it. Reproduced with a real loopback TLS handshake: a valid root / intermediate / leaf chain served as[leaf, root, intermediate], only the root trusted.Change
TrustManagerFactory.getDefaultAlgorithm()andKeyManagerFactory.getDefaultAlgorithm(), in the field initializers and ininit(...). On OpenJDK the key manager default is stillSunX509, so only the trust manager changes there; the key manager now follows the JVM elsewhere (FIPS, IBM).ssl.TrustManagerFactory.algorithm/ssl.KeyManagerFactory.algorithmsystem properties, thetrustManagerAlgorithm/keyManagerAlgorithmparameters and the setters still take precedence, soSunX509can still be selected explicitly. No new API.PKIXis the standard validation and stricter thanSunX509on unusual chains: it is mentioned inchanges.mdwith the way back.Tests
New
DefaultSslContextFactoryTestCase(10 tests), written first: 3 fail without the fix (the two defaults and the out-of-order handshake, with the reporter'sCertificate chaining error). Guards: system properties, setters andinitparameters still win, andSunX509still fails on an out-of-order chain. The test material is 4 small PEM text files and a README (test-only key, valid 100 years), no binary.verifypasses, including the existing HTTPS tests, now running onPKIX. The 2.6 Jetty extension, which also uses the factory, passes its tests too.Same fix on the other maintained versions: 3.0 #1688, 2.7 #1689.
🤖 Generated with Claude Code