Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNI: wrap wolfSSL_SessionIsSetup() in WolfSSLSession #191

Merged
merged 7 commits into from
Apr 25, 2024

Conversation

cconlon
Copy link
Member

@cconlon cconlon commented Apr 22, 2024

This PR wraps the native wolfSSL API: wolfSSL_SessionIsSetup(WOLFSSL_SESSION* session); in the static Java method WolfSSLSession.sessionIsSetup(long session).

The native session pointer can be obtained from a calling Java application by calling WolfSSLSession.getSession(). WolfSSLSession.getSession() behaves like wolfSSL_get1_session() and returns a duplicate/copy of the WOLFSSL_SESSION. Calling applications must take care to free the session pointer when done by calling WolfSSLSession.freeSession(long session).

Native wolfSSL_SessionIsSetup() was added after wolfSSL 5.7.0 with wolfSSL/wolfssl#7430. If using native wolfSSL LIBWOLFSSL_VERSION_HEX in wolfssl/version.h is not greater than 0x05007000, then WOLFSSL_PR7430_PATCH_APPLIED must be defined when compiling wolfssljni native JNI sources. java.sh can be edited to define WOLFSSL_PR7430_PATCH_APPLIED in cflags if needed.

Other changes in this PR:

  • Refactor WolfSSLSessionTest to use Junit test method annotations
  • Add test method for WolfSSLSession.get/set/freeSession()
  • In WolfSSLSession.getSession() JNI wrapper, check if session has ticket for TLS 1.3 before calling wolfSSL_peek()
  • Correctly close client/server SSLSocket in WolfSSLSocketTest.protocolConnectionTestExtendedSocket(), prevents test hang with --enable-jni --enable-all on some JDK versions
  • Fix Infer thread safety violation warnings in WolfSSLSession and WolfSSLSocket
  • Remove Java 8 testing from Temurin JDK in GitHub Actions. It looks like Java 8 was removed for Mac OSX runners, error Error: Could not find satisfied version for SemVer '8'..

ZD 17557

… 5.7.0 or WOLFSSL_PR7430_PATCH_APPLIED defined
@cconlon cconlon self-assigned this Apr 22, 2024
@NitzDKoder
Copy link

@cconlon can we please have java test code for this api usage, wolfSSL_SessionIsSetup, getSession and freeSession?

@cconlon
Copy link
Member Author

cconlon commented Apr 25, 2024

Hi @NitzDKoder, initial Java test code for the mentioned APIs has been added. Please see wolfssljni/src/test/com/wolfssl/test/WolfSSLSessionTest.java, specifically the method test_WolfSSLSession_getSetSession().

For general usage, after a WolfSSLSession.connect() call succeeds, you can call WolfSSLSession.getSession() to retrieve a long representing a native WOLFSSL_SESSION pointer. You can pass that long to WolfSSLSession.sessionIsSetup(long) which wraps the native wolfSSL_SessionIsSetup() API.

@JacobBarthelmeh JacobBarthelmeh merged commit a2db7c3 into wolfSSL:master Apr 25, 2024
35 checks passed
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.

4 participants