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_set_tls13_secret_cb() in WolfSSLSession.setTls13SecretCb() #181

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

cconlon
Copy link
Member

@cconlon cconlon commented Mar 27, 2024

This PR wraps the native wolfSSL API wolfSSL_set_tls13_secret_cb() inside the WolfSSLSession class. This allows JNI-level users to write and register a TLS 1.3 secret callback for use with Wireshark.

Native wolfSSL needs to be compiled with -DHAVE_SECRET_CALLBACK, ie:

cd wolfssl-X.X.X
./configure --enable-jni CFLAGS="-DHAVE_SECRET_CALLBACK"
make
sudo make install

Java applications need to implement the com.wolfssl.WolfSSLTls13SecretCallback interface, for example:

class MyTls13SecretCb implements WolfSSLTls13SecretCallback
{
    public int tls13SecretCallback(WolfSSLSession ssl, int id,
        byte[] secret, Object ctx)
    {
        /* Implement callback logic, see examples/MyTls13ClientCallback.java for example */
    }
}

Then provide an instance of that to WolfSSLSession.setTls13SecretCb(). For example:

WolfSSLSession ssl = ...
MyTls13SecretCb cb = new MyTls13SecretCb();

ssl.keepArrays();
ssl.setTls13SecretCb(cb, null);

For an example of using the TLS 1.3 secret callback, see the example JNI client (examples/Client.java, examples/MyTls13SecretCallback.java).

The example JNI client and server can be connected against each other with the client using the example TLS 1.3 secret callback using the following. Note that like mentioned above, native wolfSSL must be compiled with -DHAVE_SECRET_CALLBACK.

./examples/server.sh -v 4
./examples/client.sh -tls13secretcb sslkeylog.log -v 4
...
(sslkeylog.log should be available under examples/build/sslkeylog.log)

@cconlon cconlon assigned cconlon and lealem47 and unassigned cconlon Mar 27, 2024
@lealem47 lealem47 merged commit 8826635 into wolfSSL:master Mar 28, 2024
36 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.

2 participants