@@ -676,6 +676,8 @@ private native int setTlsHmacInner(long ssl, byte[] inner, long sz,
676676 private native int useSNI (long ssl , byte type , byte [] data );
677677 private native byte [] getSNIRequest (long ssl , byte type );
678678 private native int useSessionTicket (long ssl );
679+ private native byte [] getSessionTicket (long ssl );
680+ private native int setSessionTicket (long ssl , byte [] ticket );
679681 private native int gotCloseNotify (long ssl );
680682 private native int sslSetAlpnProtos (long ssl , byte [] alpnProtos );
681683 private native byte [] sslGet0AlpnSelected (long ssl );
@@ -5184,6 +5186,66 @@ public synchronized boolean sessionTicketsEnabled()
51845186 return this .sessionTicketsEnabled ;
51855187 }
51865188
5189+ /**
5190+ * Get session ticket for this session if session tickets are enabled.
5191+ *
5192+ * @return session ticket as byte array, or null if not available.
5193+ * @throws IllegalStateException WolfSSLSession has been freed.
5194+ */
5195+ public synchronized byte [] getSessionTicket () throws IllegalStateException {
5196+ if (sessionTicketsEnabled ()) {
5197+ byte [] sessionTicket = null ;
5198+ confirmObjectIsActive ();
5199+
5200+ synchronized (sslLock ) {
5201+
5202+ WolfSSLDebug .log (getClass (), WolfSSLDebug .Component .JNI ,
5203+ WolfSSLDebug .INFO , this .sslPtr ,
5204+ () -> "entered getSessionTicket()" );
5205+
5206+ sessionTicket = getSessionTicket (this .sslPtr );
5207+ }
5208+ return sessionTicket ;
5209+ } else {
5210+ WolfSSLDebug .log (getClass (), WolfSSLDebug .Component .JNI ,
5211+ WolfSSLDebug .INFO , this .sslPtr ,
5212+ () -> "session tickets not enabled, returning null" );
5213+ return null ;
5214+ }
5215+ }
5216+
5217+ /**
5218+ * Set session ticket for this session.
5219+ *
5220+ * @param sessionTicket session ticket to set for this session.
5221+ * @return WolfSSL.SSL_SUCCESS on success, otherwise negative.
5222+ *
5223+ * @throws IllegalStateException WolfSSLSession has been freed
5224+ */
5225+ public int setSessionTicket (byte [] sessionTicket ){
5226+ int ret = WolfSSL .SSL_SUCCESS ;
5227+ if (sessionTicketsEnabled ()){
5228+ confirmObjectIsActive ();
5229+ synchronized (sslLock ) {
5230+ WolfSSLDebug .log (getClass (), WolfSSLDebug .Component .JNI ,
5231+ WolfSSLDebug .INFO , this .sslPtr ,
5232+ () -> "entered setSessionTicket()" );
5233+
5234+ if (sessionTicket != null && sessionTicket .length > 0 ) {
5235+ ret = setSessionTicket (this .sslPtr , sessionTicket );
5236+ } else {
5237+ WolfSSLDebug .log (getClass (), WolfSSLDebug .Component .JNI ,
5238+ WolfSSLDebug .INFO , this .sslPtr ,
5239+ () -> "session ticket is null, not setting" );
5240+ ret = WolfSSL .SSL_FAILURE ;
5241+ }
5242+
5243+ }
5244+ }
5245+
5246+ return ret ;
5247+ }
5248+
51875249 /**
51885250 * Set ALPN extension protocol for this session from encoded byte array.
51895251 * Calls SSL_set_alpn_protos() at native level. Format starts with
0 commit comments