@@ -534,13 +534,18 @@ private void checkAndInitSSLSocket() throws IOException {
534534
535535 try {
536536 /* Load private key and cert chain from WolfSSLAuthStore */
537- WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
538- () -> "loading private key and cert chain" );
537+ if (EngineHelper != null ) {
538+ WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
539+ () -> "loading private key and cert chain" );
539540
540- if (this .socket != null ) {
541- EngineHelper .LoadKeyAndCertChain (this .socket , null );
541+ if (this .socket != null ) {
542+ EngineHelper .LoadKeyAndCertChain (this .socket , null );
543+ } else {
544+ EngineHelper .LoadKeyAndCertChain (this , null );
545+ }
542546 } else {
543- EngineHelper .LoadKeyAndCertChain (this , null );
547+ throw new WolfSSLException (
548+ "EngineHelper null, cannot load key and cert chain" );
544549 }
545550
546551 isInitialized = true ;
@@ -2067,7 +2072,9 @@ public synchronized void close() throws IOException {
20672072 (handshakeFinished == true )) {
20682073 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
20692074 () -> "saving WOLFSSL_SESSION into cache" );
2070- EngineHelper .saveSession ();
2075+ if (EngineHelper != null ) {
2076+ EngineHelper .saveSession ();
2077+ }
20712078 }
20722079 else {
20732080 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
@@ -2106,7 +2113,9 @@ public synchronized void close() throws IOException {
21062113 this .connectionClosed = true ;
21072114
21082115 /* Release native verify callback (JNI global) */
2109- this .EngineHelper .unsetVerifyCallback ();
2116+ if (this .EngineHelper != null ) {
2117+ this .EngineHelper .unsetVerifyCallback ();
2118+ }
21102119
21112120 /* Close ConsumedRecvCtx data stream */
21122121 Object readCtx = this .ssl .getIOReadCtx ();
@@ -2179,8 +2188,10 @@ public synchronized void close() throws IOException {
21792188 }
21802189
21812190 /* Reset internal WolfSSLEngineHelper to null */
2182- this .EngineHelper .clearObjectState ();
2183- this .EngineHelper = null ;
2191+ if (this .EngineHelper != null ) {
2192+ this .EngineHelper .clearObjectState ();
2193+ this .EngineHelper = null ;
2194+ }
21842195
21852196 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
21862197 () -> "thread exiting ioLock (shutdown)" );
0 commit comments