Skip to content

Keep certificate verification callback until native context disposal - #176

Merged
mayuki merged 1 commit into
mainfrom
feature/FixCertVerificationCallbackLifetime
Oct 1, 2026
Merged

mayuki merged 1 commit into
mainfrom
feature/FixCertVerificationCallbackLifetime

Conversation

@mayuki

@mayuki mayuki commented Sep 30, 2026

Copy link
Copy Markdown
Member

This PR extends the lifetime of the certificate verification callback until the handler is disposed.

This is similar to the fix in #171, but since it does not stop callback invocations on the Rust side, it is not intended as a general fix for crashes.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The lifetime change aligns callback ownership with native context retention and is covered by a focused regression test.

Review effort: Balanced
Findings: None

What changed in this PR

Retains certificate-verification callbacks for the native context lifetime, preventing active TLS requests from accessing released managed callbacks.

Changes:

  • Transfers callback ownership to YahaContextSafeHandle.
  • Releases the callback after native context disposal.
  • Adds an isolated disposal-during-handshake regression test.
File Description
src/​YetAnotherHttpHandler/​YahaSafeHandles.cs Manages callback lifetime with the native context.
src/​YetAnotherHttpHandler/​NativeHttpHandlerCore.cs Assigns callback ownership to the safe handle.
test/​YetAnotherHttpHandler.Test/​CertificateVerificationCallbackLifetimeTest.cs Verifies callback retention during an active handshake.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mayuki
mayuki merged commit 722e676 into main Oct 1, 2026
23 checks passed
@mayuki
mayuki deleted the feature/FixCertVerificationCallbackLifetime branch October 1, 2026 03:05
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