Repository navigation
ssl: reset chain in add_certificate - #1154
Merged
Merged
Conversation
When extra_certs is omitted, SSLContext#add_certificate and SSLSocket#add_certificate keep the extra certificates set earlier for the same key type. Pass a NULL chain to SSL_CTX_set0_chain() and SSL_set0_chain() to remove the earlier extra certificates. Co-authored-by: Claude Mythos 5.2 <noreply@anthropic.com>
rhenium
reviewed
Nov 17, 2026
rhenium
left a comment
Member
There was a problem hiding this comment.
Thanks for the catch!
The identical bug also exists in SSLContext#add_certificate. Could you fix it as well?
| * SSLContext#add_certificate for details. | ||
| * | ||
| * The extra certificates for the key type of _certificate_ are replaced with | ||
| * _extra_certs_, or removed if _extra_certs_ is omitted. |
Member
There was a problem hiding this comment.
This should be in the rdoc comments for SSLContext#add_certificate.
Contributor
Author
There was a problem hiding this comment.
Moved to the rdoc for SSLContext#add_certificate.
Contributor
Author
|
Thank you for review.
I've fixed |
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.
Follow-up to f5fbd44 (#1149).
SSLSocket#add_certificate(cert, key)keeps theextra_certs(intermediate CA certificates) that the socket copied from itsSSLContext. If the new certificate has the same key type as theSSLContextcertificate, the server sends the new certificate with theextra_certsof theSSLContextcertificate.SSLContext#add_certificate(cert, key)also keeps theextra_certsfrom an earlier call for the same key type.With the
servername_cbexample from #1150, the server sends the chain above when theSSLContextcertificate hasextra_certs.SSLSocket#add_certificateis not in a release yet.Fix
SSLContext#add_certificate(cert, key)andSSLSocket#add_certificate(cert, key)now drop theextra_certsset earlier for the same key type, and the server in the example above sends only the SNI certificate.