Rewrite cert_expired to root_cert_expired for cross-sign recovery#863
Merged
Conversation
OTP's ssl_certificate:find_cross_sign_root_paths/4 recovers from an
expired cross-signed root by locating an alternative valid root with
the same public key in the trust store. It only triggers when path
validation reports root_cert_expired.
ssl_verify_hostname:verify_fun/3 returns {fail, {bad_cert, cert_expired}}
verbatim, which terminates the handshake before OTP's recovery can run.
Wrap the verify_fun in check_hostname_opts/1 to intercept cert_expired
and rewrite it to root_cert_expired. All other events are delegated to
ssl_verify_hostname unchanged, so hostname checking is unaffected.
Confirmed against rest.fra-01.braze.eu (Let's Encrypt chain containing
the ISRG Root X2 cross-signed by ISRG Root X1, expired 2025-09-15)
using hackney 1.25.0, certifi 2.15.0, OTP 27.
…_fun Add regression tests that the verify_fun wrapper delegates valid and extension events to ssl_verify_hostname unchanged, and that the partial_chain option is preserved, so valid and partial certificate chains still verify after the cert_expired rewrite.
This was referenced Jun 3, 2026
Merged
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.
Rebase of #860 (by @mrnovalles) on master to get the ARM64 CI fix, with extra tests.
When the chain is anchored by an expired cross-signed root (Let's Encrypt ISRG Root X2 signed by the expired X1), OTP can recover by finding another valid root with the same key, but only when path validation reports
root_cert_expired. hackney usesssl_verify_hostname, which returnscert_expiredand stops the handshake before the recovery runs.The fix wraps the verify_fun to rewrite
cert_expiredintoroot_cert_expired. Other events go tossl_verify_hostnameas before.Safe: if no valid alternative root exists, OTP fails again as
cert_expired, so an expired leaf or intermediate still fails. Partial chains keep working:partial_chainstays, andvalid,valid_peerandextensionevents pass through. Tests added for both.Supersedes #860.