Skip to content

Commit

Permalink
Merge pull request #241 from rlm2002/sniServerNames
Browse files Browse the repository at this point in the history
Add getSNIRequestBytes() and modify return value of getSNIRequest()
  • Loading branch information
cconlon authored Dec 12, 2024
2 parents 21beea3 + 8647c69 commit 8ae65d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
25 changes: 21 additions & 4 deletions src/java/com/wolfssl/WolfSSLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -4105,16 +4105,16 @@ public synchronized byte[] getClientSNIRequest()
}

/**
* Get SNI request used for this session object.
* Get SNI request used for this session object as bytes.
*
* @param type SNI type. Currently supported type is
* WolfSSL.WOLFSSL_SNI_HOST_NAME.
* @return String representing SNI name requested in this session, or
* @return SNI name requested in this session as a byte array, or
* null if not available.
* @throws IllegalStateException if called when WolfSSLSession is not
* active
*/
public String getSNIRequest(byte type) throws IllegalStateException {
public byte[] getSNIRequestBytes(byte type) throws IllegalStateException {

byte[] reqBytes = null;

Expand All @@ -4130,12 +4130,29 @@ public String getSNIRequest(byte type) throws IllegalStateException {
}

if (reqBytes != null) {
return reqBytes.toString();
return reqBytes;
}

return null;
}

/**
* Get SNI request used for this session object as String.
*
* @param type SNI type. Currently supported type is
* WolfSSL.WOLFSSL_SNI_HOST_NAME.
* @return String representing SNI name requested in this session, or
* null if not available.
* @throws IllegalStateException if called when WolfSSLSession is not
* active
*/
public String getSNIRequest(byte type) throws IllegalStateException {

confirmObjectIsActive();

return new String(getSNIRequestBytes(type), StandardCharsets.UTF_8);
}

/**
* Enable session tickets for this session.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ public synchronized List<SNIServerName> getRequestedServerNames()
if (this.ssl.getSide() == WolfSSL.WOLFSSL_CLIENT_END){
sniRequestArr = this.ssl.getClientSNIRequest();
} else {
sniRequestArr = this.ssl.getSNIRequest((byte)WolfSSL.
WOLFSSL_SNI_HOST_NAME).getBytes();
sniRequestArr = this.ssl.getSNIRequestBytes((byte)WolfSSL.
WOLFSSL_SNI_HOST_NAME);
}

if (sniRequestArr != null) {
Expand Down

0 comments on commit 8ae65d4

Please sign in to comment.