Fix global ref lifecycle for verify and missing-CRL callbacks#369
Open
cconlon wants to merge 1 commit intowolfSSL:masterfrom
Open
Fix global ref lifecycle for verify and missing-CRL callbacks#369cconlon wants to merge 1 commit intowolfSSL:masterfrom
cconlon wants to merge 1 commit intowolfSSL:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes JNI global-ref lifecycle issues by making the verify callback reference per-WOLFSSL_CTX (via ex_data) and adjusting missing-CRL callback cleanup to only happen at library unload.
Changes:
- Store per-context verify callback
jobjectinWOLFSSL_CTX ex_dataand resolve it inNativeVerifyCallback(). - Move missing-CRL callback global-ref cleanup to
JNI_OnUnload()via new cleanup helpers. - Add a JUnit test covering multi-context
setVerify()install/replace/unregister/free flows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/com/wolfssl/test/WolfSSLContextTest.java | Adds a multi-context setVerify() lifecycle test intended to surface global-ref mishandling. |
| native/com_wolfssl_globals.h | Declares the ex_data index global and new cleanup helper prototypes. |
| native/com_wolfssl_WolfSSLSession.c | Adds JNI_OnUnload() cleanup for the process-global session missing-CRL callback; stops freeing it in freeSSL(). |
| native/com_wolfssl_WolfSSLContext.c | Moves verify callback storage to per-CTX ex_data, adds CTX-level missing-CRL cleanup helper, and adjusts freeContext() cleanup. |
| native/com_wolfssl_WolfSSL.c | Allocates the ex_data index during WolfSSL_init() and calls cleanup helpers in JNI_OnUnload(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8e1a905 to
b0b710f
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #369
Scan targets checked: wolfssljni-bugs, wolfssljni-src
No new issues found in the changed files. ✅
b0b710f to
3935575
Compare
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.
This PR fixes a JNI callback global reference lifecycle bug where
setVerify()/setCRLCb()on oneWolfSSLContextorWolfSSLSessioncould delete a still-live callback reference held by another instance.staticto per-WOLFSSL_CTXex_data, allocated inJava_com_wolfssl_WolfSSL_init()afterwolfSSL_Init().NativeVerifyCallback()now resolves the callback viastore->ssl->ctx->ex_data, so each context fires its own user callback.CbMissingCRLhas no SSL/CTX argument), but stops deleting them infreeContext()/freeSSL(). OnlysetCRLCb()overwrites andJNI_OnUnload()release them.NativeWolfSSLContextCleanup()/NativeWolfSSLSessionCleanup()helpers called fromJNI_OnUnload()for library-level cleanup of globals.test_WolfSSLContext_setVerifyMultipleContexts()exercising the multi-context install / replace / unregister / interleaved-free lifecycle.Fixes F-1024.