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

Add JNI Java level debugging with System Property: wolfssljni.debug=true #235

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

cconlon
Copy link
Member

@cconlon cconlon commented Nov 20, 2024

This PR adds debug logging to JNI-level classes (com.wolfssl) with the introduction of a new System property called wolfssljni.debug=true. This can be set from the command line:

-Dwolfssljni.debug=true

Or programmatically from code:

System.setProperty("wolfssljni.debug", "true");

With this new feature the following changes were made:

  • WolfSSLDebug.java class was moved from com.wolfssl.provider.jsse package down to the lower level com.wolfssl package, so the same class could be used for both JNI and JSSE level debug capabilities.
  • Log messages were added to existing JNI-level classes
  • JNI-level debug logs now include the native structure pointer as part of the log message header

Logs will look similar to:

2024-11-20 15:38:02.126 [wolfJNI INFO: TID 1: WolfSSL] loading native library: wolfssl
2024-11-20 15:38:02.131 [wolfJNI INFO: TID 1: WolfSSL] loading native library: wolfssljni
2024-11-20 15:38:02.132 [wolfJNI INFO: TID 1: WolfSSL] initializing wolfSSL library
2024-11-20 15:38:02.134 [wolfJNI INFO: TID 1: WolfSSL: 140241554155520] creating new WolfSSLContext
2024-11-20 15:38:02.135 [wolfJNI INFO: TID 1: WolfSSLContext: 140241554155520] entered useCertificateFile(../certs/client-cert.pem, 1)
2024-11-20 15:38:02.135 [wolfJNI INFO: TID 1: WolfSSLContext: 140241554155520] entered usePrivateKeyFile(../certs/client-key.pem, 1)
2024-11-20 15:38:02.136 [wolfJNI INFO: TID 1: WolfSSLContext: 140241554155520] entered loadVerifyLocations(../certs/ca-cert.pem, null)
2024-11-20 15:38:02.136 [wolfJNI INFO: TID 1: WolfSSLContext: 140241554155520] entered setVerify(1, VerifyCallback@49476842)
2024-11-20 15:38:02.14 [wolfJNI INFO: TID 1: WolfSSLSession: 140241403140608] creating new WolfSSLSession
2024-11-20 15:38:02.14 [wolfJNI INFO: TID 1: WolfSSLSession: 140241403140608] entered enableCRL(1)
2024-11-20 15:38:02.14 [wolfJNI INFO: TID 1: WolfSSLSession: 140241403140608] entered loadCRL(../certs/crl, type: 1, monitor: 0)
2024-11-20 15:38:02.142 [wolfJNI INFO: TID 1: WolfSSLSession: 140241403140608] entered setCRLCb(MyMissingCRLCallback@5451c3a8)
2024-11-20 15:38:02.142 [wolfJNI INFO: TID 1: WolfSSLSession: 140241403140608] entered useSessionTicket()
...

@JacobBarthelmeh
Copy link
Contributor

Code changes look good. The debug configuration -Dwolfssljni.debug=true needs added as an additional test case to one of the CI tests though.

@cconlon
Copy link
Member Author

cconlon commented Nov 21, 2024

Thanks, good suggestion. Please see newly-added test called test_WolfSSLSession_connectionWithDebug() inside ./src/test/com/wolfssl/test/WolfSSLSessionTest.java.

@JacobBarthelmeh JacobBarthelmeh merged commit 6e69cb2 into wolfSSL:master Nov 22, 2024
38 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.

3 participants