Skip to content

Fix #1397: use the JVM default trust and key manager algorithms - #1689

Merged
thboileau-git merged 1 commit into
2.7from
fix/1397-ssl-default-algorithms-2.7
Nov 23, 2026
Merged

thboileau-git merged 1 commit into
2.7from
fix/1397-ssl-default-algorithms-2.7

Conversation

@thboileau-git

@thboileau-git thboileau-git commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1397.

Problem

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 ValidatorException: 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

  • The defaults are now TrustManagerFactory.getDefaultAlgorithm() and KeyManagerFactory.getDefaultAlgorithm(), in the field initializers and in init(...). On OpenJDK the key manager default is still SunX509, so only the trust manager changes there; the key manager now follows the JVM elsewhere (FIPS, IBM).
  • The ssl.TrustManagerFactory.algorithm / ssl.KeyManagerFactory.algorithm system properties, the trustManagerAlgorithm / keyManagerAlgorithm parameters and the setters still take precedence, so SunX509 can still be selected explicitly. No new API.
  • PKIX is the standard validation and stricter than SunX509 on unusual chains: it is mentioned in changes.md with 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's Certificate chaining error). Guards: system properties, setters and init parameters still win, and SunX509 still 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.
verify passes, including the existing HTTPS tests, now running on PKIX.

Same fix on the other maintained versions: 3.0 #1688, 2.6 #1690.

🤖 Generated with Claude Code

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>
@sonarqubecloud

Copy link
Copy Markdown

@thboileau-git
thboileau-git merged commit e5cf90a into 2.7 Nov 23, 2026
6 checks passed
@thboileau-git
thboileau-git deleted the fix/1397-ssl-default-algorithms-2.7 branch November 23, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The trustmanager algorithm SunX509 is outdated, which causes an exception if certificate chain is out of order, but valid

1 participant