6767public class ClientConnFactoryBuilder {
6868
6969 private static final Log log = LogFactory .getLog (ClientConnFactoryBuilder .class );
70+ private static final boolean skipSslProfileFailures =
71+ Boolean .parseBoolean (System .getProperty (NhttpConstants .SSL_PROFILE_SKIP_FAILURES ));
7072
7173 private final TransportOutDescription transportOut ;
7274 private final String name ;
@@ -277,6 +279,16 @@ private Map<RequestDescriptor, SSLContext> getCustomSSLContexts(TransportOutDesc
277279 sslContext = createSSLContext (ksElt , trElt , novalidatecert , secretResolver );
278280 } catch (AxisFault axisFault ) {
279281 String err = "Error occurred while creating SSL context for the servers " + serversElt .getText ();
282+ if (skipSslProfileFailures ) {
283+ if (log .isWarnEnabled ()) {
284+ String cause = axisFault .getCause () != null
285+ ? axisFault .getCause ().getClass ().getName () + ": " + axisFault .getCause ().getMessage ()
286+ : axisFault .getMessage ();
287+ log .warn (name + " " + err + ". Skipping this SSL profile and continuing "
288+ + "with the remaining profiles. Cause: " + cause );
289+ }
290+ continue ;
291+ }
280292 // This runtime exception stop the server startup But it will not affect for dynamic change
281293 throw new InvalidConfigurationException (err , axisFault );
282294 }
@@ -307,6 +319,16 @@ private Map<RequestDescriptor, SSLContext> getCustomSSLContexts(TransportOutDesc
307319 sslContext = createSSLContext (ksElt , trElt , novalidatecert , secretResolver );
308320 } catch (AxisFault axisFault ) {
309321 String err = "Error occurred while creating SSL context for the servers " + serversElt .getText ();
322+ if (skipSslProfileFailures ) {
323+ if (log .isWarnEnabled ()) {
324+ String cause = axisFault .getCause () != null
325+ ? axisFault .getCause ().getClass ().getName () + ": " + axisFault .getCause ().getMessage ()
326+ : axisFault .getMessage ();
327+ log .warn (name + " " + err + ". Skipping this SSL profile and continuing "
328+ + "with the remaining profiles. Cause: " + cause );
329+ }
330+ continue ;
331+ }
310332 // This runtime exception stop the server startup But it will not affect for dynamic change
311333 throw new InvalidConfigurationException (err , axisFault );
312334 }
@@ -485,10 +507,14 @@ private SSLContext createSSLContext(OMElement keyStoreElt, OMElement trustStoreE
485507 keymanagers = kmfactory .getKeyManagers ();
486508
487509 } catch (GeneralSecurityException gse ) {
488- log .error (name + " Error loading Keystore : " + location , gse );
510+ if (!skipSslProfileFailures ) {
511+ log .error (name + " Error loading Keystore : " + location , gse );
512+ }
489513 throw new AxisFault ("Error loading Keystore : " + location , gse );
490514 } catch (IOException ioe ) {
491- log .error (name + " Error opening Keystore : " + location , ioe );
515+ if (!skipSslProfileFailures ) {
516+ log .error (name + " Error opening Keystore : " + location , ioe );
517+ }
492518 throw new AxisFault ("Error opening Keystore : " + location , ioe );
493519 }
494520 }
@@ -521,10 +547,14 @@ private SSLContext createSSLContext(OMElement keyStoreElt, OMElement trustStoreE
521547 sslSenderTrustStoreHolder .setPassword (storePassword );
522548
523549 } catch (GeneralSecurityException gse ) {
524- log .error (name + " Error loading Key store : " + location , gse );
550+ if (!skipSslProfileFailures ) {
551+ log .error (name + " Error loading Key store : " + location , gse );
552+ }
525553 throw new AxisFault ("Error loading Key store : " + location , gse );
526554 } catch (IOException ioe ) {
527- log .error (name + " Error opening Key store : " + location , ioe );
555+ if (!skipSslProfileFailures ) {
556+ log .error (name + " Error opening Key store : " + location , ioe );
557+ }
528558 throw new AxisFault ("Error opening Key store : " + location , ioe );
529559 }
530560 } else if (novalidatecert ) {
@@ -543,7 +573,9 @@ private SSLContext createSSLContext(OMElement keyStoreElt, OMElement trustStoreE
543573 return sslcontext ;
544574
545575 } catch (GeneralSecurityException gse ) {
546- log .error (name + " Unable to create SSL context with the given configuration" , gse );
576+ if (!skipSslProfileFailures ) {
577+ log .error (name + " Unable to create SSL context with the given configuration" , gse );
578+ }
547579 throw new AxisFault ("Unable to create SSL context with the given configuration" , gse );
548580 }
549581 }
0 commit comments