Skip to content

ocsp: add single-cert stapling fast path and certinfo RAII#13229

Open
c-taylor wants to merge 2 commits into
apache:masterfrom
c-taylor:ocsp-stapling-map-lifecycle
Open

ocsp: add single-cert stapling fast path and certinfo RAII#13229
c-taylor wants to merge 2 commits into
apache:masterfrom
c-taylor:ocsp-stapling-map-lifecycle

Conversation

@c-taylor

@c-taylor c-taylor commented Jun 2, 2026

Copy link
Copy Markdown

Skip the SSL_get_certificate() lookup and X509_cmp() DER re-parse in the stapling callback when an SSL_CTX has a single certificate. The shortcut is gated to non-dual-cert builds; under HAVE_NATIVE_DUAL_CERT_SUPPORT a CTX can hold multiple certs where only one has OCSP info, so map size alone cannot identify the negotiated cert.

Give certinfo a constructor/destructor so its resources are managed by RAII, and allocate it with make_unique. This consolidates the cleanup that was duplicated across certinfo_map_free and the init error path, and fixes two pre-existing leaks (cid and the BoringSSL cert ref) plus an error path that could delete a certinfo_map still owned by the SSL_CTX.

Skip the SSL_get_certificate() lookup and X509_cmp() DER re-parse in the
stapling callback when an SSL_CTX has a single certificate. The shortcut
is gated to non-dual-cert builds; under HAVE_NATIVE_DUAL_CERT_SUPPORT a
CTX can hold multiple certs where only one has OCSP info, so map size
alone cannot identify the negotiated cert.

Give certinfo a constructor/destructor so its resources are managed by
RAII, and allocate it with make_unique. This consolidates the cleanup
that was duplicated across certinfo_map_free and the init error path,
and fixes two pre-existing leaks (cid and the BoringSSL cert ref) plus
an error path that could delete a certinfo_map still owned by the
SSL_CTX.
Comment thread src/iocore/net/OCSPStapling.cc Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Switch the per-SSL_CTX certinfo map to store std::unique_ptr<certinfo>
so ownership is explicit and the value cleanup is handled by RAII. This
removes the manual delete in certinfo_map_free and closes a leak window
at the insert site: the old release()-then-insert dropped the pointer if
the key already existed or the insert threw, whereas emplace with a move
only transfers ownership once insertion succeeds.
@c-taylor c-taylor requested a review from bneradt June 8, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@bryancall

Copy link
Copy Markdown
Contributor

@c-taylor Do you want us to merge this in to master?

@c-taylor c-taylor marked this pull request as ready for review June 8, 2026 23:00
@c-taylor

c-taylor commented Jun 8, 2026

Copy link
Copy Markdown
Author

Local validations were in progress since my last commit for @bneradt - Good here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants