Skip to content

Release resources used by SSL diagnostic output - #3657

Open
wasphin wants to merge 1 commit into
apache:masterfrom
wasphin:fix-ssl-diagnostic-ownership
Open

wasphin wants to merge 1 commit into
apache:masterfrom
wasphin:fix-ssl-diagnostic-ownership

Conversation

@wasphin

@wasphin wasphin commented Oct 25, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Problem Summary:

Printing an SSL session obtains an owning peer-certificate reference, and printing a certificate allocates a BIO. Repeated diagnostic output retains both resources.

What is changed and the side effects?

Changed:

  • Manage the peer certificate and diagnostic BIO with scoped owners.
  • Add an in-memory TLS regression that verifies the peer certificate is released after repeated diagnostic output.

Side effects:

  • Performance effects: Releases temporary resources after each diagnostic call.
  • Breaking backward compatibility: None for valid inputs.

Check List:

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.

🟡 Changes recommended

The new regression needs a MesaLink guard because that backend does not emit the certificate fields it asserts.

1 open issue
What changed in this PR

This PR fixes temporary resource leaks in bRPC’s SSL diagnostic output.

Changes:

  • Adds scoped ownership for peer certificates and diagnostic BIO buffers.
  • Adds an in-memory TLS regression checking certificate release after repeated diagnostic output.
File Description
test/​brpc_ssl_unittest.cpp Adds regression coverage for peer-certificate cleanup.
src/​brpc/​details/​ssl_helper.cpp Automatically releases certificate references and BIO buffers.

Review effort: Balanced

Comment on lines +150 to +151
EXPECT_NE(std::string::npos, os.str().find("peer_certificate={"));
EXPECT_NE(std::string::npos, os.str().find("subject="));
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.

2 participants