private SSLContext createSSLContext ( ) throws ClientSslSocketFactoryException { final KeyManager [ ] keyManagers = this . keyStore != null ? createKeyManagers ( ) : null ; final TrustManager [ ] trustManagers = this . trustStore != null ? createTrustManagers ( ) : null ; try { final SSLContext sslcontext = SSLContext . getInstance ( SOCKET_ALGORITHM ) ; sslcontext . init ( keyManagers , trustManagers , null ) ; return sslcontext ; } catch ( NoSuchAlgorithmException e ) { throw new ClientSslSocketFactoryException ( String . format ( "Failed to create an SSL context that supports algorithm %s: %s" , SOCKET_ALGORITHM , e . getMessage ( ) ) , e ) ; } catch ( KeyManagementException e ) { throw new ClientSslSocketFactoryException ( String . format ( "Failed to initialize an SSL context: %s" , e . getMessage ( ) ) , e ) ; } }
Creates the SSL context needed to create the socket factory used by this factory . The key and trust store parameters are optional . If they are null then the JRE defaults will be used .