Skip to content

Commit 8ae65d4

Browse files
authored
Merge pull request #241 from rlm2002/sniServerNames
Add getSNIRequestBytes() and modify return value of getSNIRequest()
2 parents 21beea3 + 8647c69 commit 8ae65d4

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/java/com/wolfssl/WolfSSLSession.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,16 +4105,16 @@ public synchronized byte[] getClientSNIRequest()
41054105
}
41064106

41074107
/**
4108-
* Get SNI request used for this session object.
4108+
* Get SNI request used for this session object as bytes.
41094109
*
41104110
* @param type SNI type. Currently supported type is
41114111
* WolfSSL.WOLFSSL_SNI_HOST_NAME.
4112-
* @return String representing SNI name requested in this session, or
4112+
* @return SNI name requested in this session as a byte array, or
41134113
* null if not available.
41144114
* @throws IllegalStateException if called when WolfSSLSession is not
41154115
* active
41164116
*/
4117-
public String getSNIRequest(byte type) throws IllegalStateException {
4117+
public byte[] getSNIRequestBytes(byte type) throws IllegalStateException {
41184118

41194119
byte[] reqBytes = null;
41204120

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

41324132
if (reqBytes != null) {
4133-
return reqBytes.toString();
4133+
return reqBytes;
41344134
}
41354135

41364136
return null;
41374137
}
41384138

4139+
/**
4140+
* Get SNI request used for this session object as String.
4141+
*
4142+
* @param type SNI type. Currently supported type is
4143+
* WolfSSL.WOLFSSL_SNI_HOST_NAME.
4144+
* @return String representing SNI name requested in this session, or
4145+
* null if not available.
4146+
* @throws IllegalStateException if called when WolfSSLSession is not
4147+
* active
4148+
*/
4149+
public String getSNIRequest(byte type) throws IllegalStateException {
4150+
4151+
confirmObjectIsActive();
4152+
4153+
return new String(getSNIRequestBytes(type), StandardCharsets.UTF_8);
4154+
}
4155+
41394156
/**
41404157
* Enable session tickets for this session.
41414158
*

src/java/com/wolfssl/provider/jsse/WolfSSLImplementSSLSession.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,8 @@ public synchronized List<SNIServerName> getRequestedServerNames()
962962
if (this.ssl.getSide() == WolfSSL.WOLFSSL_CLIENT_END){
963963
sniRequestArr = this.ssl.getClientSNIRequest();
964964
} else {
965-
sniRequestArr = this.ssl.getSNIRequest((byte)WolfSSL.
966-
WOLFSSL_SNI_HOST_NAME).getBytes();
965+
sniRequestArr = this.ssl.getSNIRequestBytes((byte)WolfSSL.
966+
WOLFSSL_SNI_HOST_NAME);
967967
}
968968

969969
if (sniRequestArr != null) {

0 commit comments

Comments
 (0)