@@ -55,8 +55,19 @@ public class WolfSSLContext extends SSLContextSpi {
5555 private com .wolfssl .WolfSSLContext ctx = null ;
5656 private WolfSSLParameters params = null ;
5757
58+ /* Created during construction to allow access before init() is called */
59+ private WolfSSLSessionContext serverSessionCtx = null ;
60+ private WolfSSLSessionContext clientSessionCtx = null ;
61+
62+ /* Default session cache size of 33 to match native wolfSSL default */
63+ private static final int DEFAULT_CACHE_SIZE = 33 ;
64+
5865 private WolfSSLContext (TLS_VERSION version ) {
5966 this .currentVersion = version ;
67+ this .serverSessionCtx = new WolfSSLSessionContext (
68+ DEFAULT_CACHE_SIZE , WolfSSL .WOLFSSL_SERVER_END );
69+ this .clientSessionCtx = new WolfSSLSessionContext (
70+ DEFAULT_CACHE_SIZE , WolfSSL .WOLFSSL_CLIENT_END );
6071 }
6172
6273 private void createCtx () throws WolfSSLException {
@@ -399,10 +410,15 @@ protected void engineInit(KeyManager[] km, TrustManager[] tm,
399410 Arrays .toString (tm ) + ", sr=" + sr +")" );
400411
401412 try {
402- authStore = new WolfSSLAuthStore (km , tm , sr , currentVersion );
413+ authStore = new WolfSSLAuthStore (km , tm , sr , currentVersion ,
414+ this .serverSessionCtx , this .clientSessionCtx );
403415 params = new WolfSSLParameters ();
404416 createCtx ();
405417
418+ /* Link authStore to session contexts for session operations */
419+ this .serverSessionCtx .setWolfSSLAuthStore (authStore );
420+ this .clientSessionCtx .setWolfSSLAuthStore (authStore );
421+
406422 } catch (IllegalArgumentException iae ) {
407423 throw new KeyManagementException (iae );
408424
@@ -507,21 +523,27 @@ protected SSLEngine engineCreateSSLEngine(String host, int port)
507523 /**
508524 * Returns the SSLServerSessionContext associated with this SSLContext.
509525 *
510- * @throws UnsupportedOperationException operation not yet supported
526+ * Session contexts are created during SSLContext construction to allow
527+ * access before init() is called.
528+ *
529+ * @return SSLSessionContext for server sessions
511530 */
512531 @ Override
513532 protected SSLSessionContext engineGetServerSessionContext () {
514- return authStore . getServerContext () ;
533+ return this . serverSessionCtx ;
515534 }
516535
517536 /**
518537 * Returns the SSLClientSessionContext associated with this SSLContext.
519538 *
520- * @throws UnsupportedOperationException operation not yet supported
539+ * Session contexts are created during SSLContext construction to allow
540+ * access before init() is called.
541+ *
542+ * @return SSLSessionContext for client sessions
521543 */
522544 @ Override
523545 protected SSLSessionContext engineGetClientSessionContext () {
524- return authStore . getClientContext () ;
546+ return this . clientSessionCtx ;
525547 }
526548
527549 /**
0 commit comments