Release native verify callback when SSLEngine is closed #180
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 modifies
SSLEngine
so that it explicitly releases the native wolfSSL verify callback when the SSLEngine enters the CLOSED state. Once CLOSED, an SSLEngine will not be reused. From the Javadocs for SSLEngine, "Once an engine is closed, it is not reusable: a new SSLEngine must be created."The native verify callback is stored as a JNI global variable, which can hold up garbage collection if not explicitly released. Prior to this PR it was being released/freed when the native
WOLFSSL
structure was freed, but with the changes in #159, the circular reference between SSLEngine and WolfSSLInternalVerifyCallback prevented SSLEngine objects from being garbage collected.