Skip to content

Commit 424d4c0

Browse files
Merge pull request #175 from cconlon/getSessionCheckForTicket
Check TLS 1.3 session for ticket before saving to Java cache
2 parents bde6836 + 21e3505 commit 424d4c0

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

native/com_wolfssl_WolfSSLSession.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,12 +1390,18 @@ JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_get1Session
13901390
sess = wolfSSL_get_session(ssl);
13911391
}
13921392

1393-
/* wolfSSL checks ssl for NULL, returns pointer to new WOLFSSL_SESSION,
1394-
* Returns new duplicated WOLFSSL_SESSION. Needs to be freed with
1395-
* wolfSSL_SESSION_free() when finished with pointer. */
1396-
if (sess != NULL) {
1397-
/* Guarantee that we own the WOLFSSL_SESSION, make a copy */
1398-
dup = wolfSSL_SESSION_dup(sess);
1393+
/* Only duplicate / save session if not TLS 1.3 (will be using normal
1394+
* session IDs), or is TLS 1.3 and we have a session ticket */
1395+
if ((wolfSSL_version(ssl) != TLS1_3_VERSION) ||
1396+
(wolfSSL_SESSION_has_ticket((const WOLFSSL_SESSION*)sess))) {
1397+
1398+
/* wolfSSL checks ssl for NULL, returns pointer to new WOLFSSL_SESSION,
1399+
* Returns new duplicated WOLFSSL_SESSION. Needs to be freed with
1400+
* wolfSSL_SESSION_free() when finished with pointer. */
1401+
if (sess != NULL) {
1402+
/* Guarantee that we own the WOLFSSL_SESSION, make a copy */
1403+
dup = wolfSSL_SESSION_dup(sess);
1404+
}
13991405
}
14001406

14011407
if (wc_UnLockMutex(jniSessLock) != 0) {

0 commit comments

Comments
 (0)