Skip to content

Commit 2e899cc

Browse files
committed
JSSE: generate pseudo session ID if session tickets are being used
1 parent 0b6b739 commit 2e899cc

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/java/com/wolfssl/WolfSSLSession.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public class WolfSSLSession {
6565
private WolfSSLIORecvCallback internRecvSSLCb;
6666
private WolfSSLIOSendCallback internSendSSLCb;
6767

68+
/* have session tickets been enabled for this session? */
69+
private boolean sessionTicketsEnabled = true;
70+
6871
/* is this context active, or has it been freed? */
6972
private boolean active = false;
7073

@@ -2720,10 +2723,33 @@ public int useSNI(byte type, byte[] data) throws IllegalStateException {
27202723
*/
27212724
public int useSessionTicket() throws IllegalStateException {
27222725

2726+
int ret;
2727+
2728+
if (this.active == false)
2729+
throw new IllegalStateException("Object has been freed");
2730+
2731+
ret = useSessionTicket(getSessionPtr());
2732+
if (ret == WolfSSL.SSL_SUCCESS) {
2733+
this.sessionTicketsEnabled = true;
2734+
}
2735+
2736+
return ret;
2737+
}
2738+
2739+
/**
2740+
* Determine if session tickets have been enabled for this session.
2741+
* Session tickets can be enabled for this session by calling
2742+
* WolfSSLSession.useSessionTicket().
2743+
*
2744+
* @return true if enabled, otherwise false.
2745+
* @throws IllegalStateException WolfSSLSession has been freed
2746+
*/
2747+
public boolean sessionTicketsEnabled() throws IllegalStateException {
2748+
27232749
if (this.active == false)
27242750
throw new IllegalStateException("Object has been freed");
27252751

2726-
return useSessionTicket(getSessionPtr());
2752+
return this.sessionTicketsEnabled;
27272753
}
27282754

27292755
/**

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ public synchronized byte[] getId() {
137137
return new byte[0];
138138
}
139139
try {
140-
if (this.ssl.getVersion().equals("TLSv1.3")) {
140+
/* use pseudo session ID if session tickets are being used */
141+
if (this.ssl.getVersion().equals("TLSv1.3") ||
142+
this.ssl.sessionTicketsEnabled()) {
141143
return this.pseudoSessionID;
142144
}
143145
else {

0 commit comments

Comments
 (0)