@ Override public SSLContext getSSLContext ( ) throws KeyManagementException , UnrecoverableKeyException , NoSuchAlgorithmException , KeyStoreException { final SSLContext context = SSLContext . getInstance ( "TLS" ) ; String httpProtocols = System . getProperty ( "https.protocols" ) ; System . setProperty ( "https.protocols" , "TLSv1" ) ; if ( httpProtocols != null ) { System . setProperty ( "https.protocols" , httpProtocols ) ; } final KeyManagerFactory keyManagerFactory = KeyManagerFactory . getInstance ( KeyManagerFactory . getDefaultAlgorithm ( ) ) ; keyManagerFactory . init ( keystore , keystorePassword . toCharArray ( ) ) ; context . init ( keyManagerFactory . getKeyManagers ( ) , new TrustManager [ ] { new X509TrustManager ( ) { @ Override public X509Certificate [ ] getAcceptedIssuers ( ) { return new X509Certificate [ ] { } ; } @ Override public void checkClientTrusted ( final X509Certificate [ ] arg0 , final String arg1 ) { } @ Override public void checkServerTrusted ( final X509Certificate [ ] arg0 , final String arg1 ) { } } } , new SecureRandom ( ) ) ; return context ; }
Get the SSL Context out of the keystore .