Skip to content

Add wrapper for wolfSSL_SNI_GetFromBuffer()#339

Open
cconlon wants to merge 1 commit intowolfSSL:masterfrom
cconlon:sniBuffer
Open

Add wrapper for wolfSSL_SNI_GetFromBuffer()#339
cconlon wants to merge 1 commit intowolfSSL:masterfrom
cconlon:sniBuffer

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Feb 26, 2026

This PR adds a static WolfSSL.getSNIFromBuffer() method, wrapping native wolfSSL_SNI_GetFromBuffer(), allowing SNI extraction from a raw ClientHello buffer without requiring an SSL context or session.

Also adds JUnit test with mock TLS 1.2 ClientHello containing SNI.

ZD 21200

@cconlon cconlon self-assigned this Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 22:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a JNI wrapper for the native wolfSSL_SNI_GetFromBuffer() function, enabling extraction of Server Name Indication (SNI) from raw ClientHello buffers without requiring an SSL context or session. This is useful for SNI-based routing scenarios where the server needs to inspect the SNI before establishing the TLS session.

Changes:

  • Added WolfSSL.getSNIFromBuffer() static native method for extracting SNI from ClientHello buffers
  • Implemented corresponding JNI native function with proper parameter validation and error handling
  • Added comprehensive JUnit test with hand-crafted TLS 1.2 ClientHello message

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/java/com/wolfssl/WolfSSL.java Added public static native method getSNIFromBuffer() with JavaDoc documentation
native/com_wolfssl_WolfSSL.h Added JNI function declaration for the new method
native/com_wolfssl_WolfSSL.c Implemented JNI wrapper with parameter validation, memory management, and exception handling for both HAVE_SNI and non-SNI builds
src/test/com/wolfssl/test/WolfSSLTest.java Added test method that constructs a minimal TLS 1.2 ClientHello with SNI and validates extraction, including null parameter tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cconlon cconlon changed the title JNI: add wrapper for wolfSSL_SNI_GetFromBuffer() Add wrapper for wolfSSL_SNI_GetFromBuffer() Feb 26, 2026
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