add allowSha1Certificates option to work around JDK 21.0.10 TLS regression#103
Merged
jaredstehler merged 2 commits intomasterfrom Mar 12, 2026
Merged
add allowSha1Certificates option to work around JDK 21.0.10 TLS regression#103jaredstehler merged 2 commits intomasterfrom
jaredstehler merged 2 commits intomasterfrom
Conversation
…ssion JDK 21.0.10 added SHA1 jdkCA & usage TLSServer to jdk.certpath.disabledAlgorithms, causing handshake failures against IMAP servers that present SHA-1 signed certificates chaining to a JDK-bundled CA. This is a breaking change for existing mailbox connections. Rather than globally modifying JVM security properties (which would affect all connections in the process), this adds an opt-in allowSha1Certificates() flag on ImapClientConfiguration. When set, a custom X509ExtendedTrustManager is used that bypasses CertPathValidator (which enforces the disabled algorithm policy) and instead validates the chain manually via cert.verify(), which the JDK still supports for SHA-1 at the crypto layer. Standard trust validation still applies: certs must chain to a trusted CA, must not be expired, and signatures must be cryptographically valid. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests to verify the two workarounds for JDK 21.0.10 TLS regressions: - StaticRsaCipherSuiteIT verifies that sslCipherSuites re-enables static-RSA key exchange against a Python simulation server that only accepts those suites - Two new SHA-1 tests spin up a self-contained Java TLS server with a SHA-1 signed cert to verify that allowSha1Certificates=true allows connection and that the default configuration (no custom truststore) is correctly rejected Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
JDK 21.0.10 added
SHA1 jdkCA&usage TLSServertojdk.certpath.disabledAlgorithms, causing TLS handshake failures against IMAP servers that present SHA-1 signed certificates chaining to a JDK-bundled CA. Thisis a breaking change for callers connecting to legacy mailbox servers.
Rather than globally modifying JVM security properties (which would affect all SSL connections in the process), this adds an opt-in
allowSha1Certificates()flag onImapClientConfiguration.When set, a custom
X509ExtendedTrustManagerbypassesCertPathValidator(which enforces the disabled algorithm policy) and instead validates the chain manually viacert.verify(), which the JDK still supports forSHA-1 at the crypto layer. Standard trust validation still applies: certs must chain to a trusted CA, must not be expired, and signatures must be cryptographically valid — only the algorithm-strength policy
check is relaxed.
Also adds
sslCipherSuites()toImapClientConfigurationto allow re-enabling static-RSA key exchange cipher suites, which JDK 21.0.10 also disabled by default (breaking connections to servers that don't supportECDHE).
Usage:
Tests added:
itConnectsToRsaOnlyServerWithStaticRsaCipherSuites— verifies sslCipherSuites re-enables static-RSA key exchange against a Python simulation server that only accepts those suitesitConnectsToSha1CertServerWithAllowSha1Certificates— spins up a self-contained Java TLS server with a SHA-1 signed cert and verifies the flag enables connectionitFailsConnectingToSha1ServerWithoutAllowSha1Certificates— verifies the default configuration correctly rejects the SHA-1 server