private SSLEngine getSSLEngine ( ) throws KeyStoreException , CertificateException , IOException , UnrecoverableKeyException , KeyManagementException { // Open the KeyStore Stream final StreamManager streamManager = new StreamManager ( ) ; SSLContext ctx ; KeyManagerFactory kmf ; try { final InputStream ksStream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( KEYSTORE_NAME ) ; streamManager . handle ( ksStream ) ; ctx = SSLContext . getInstance ( "SSLv3" ) ; kmf = KeyManagerFactory . getInstance ( KeyManagerFactory . getDefaultAlgorithm ( ) ) ; final KeyStore ks = KeyStore . getInstance ( "JKS" ) ; char [ ] passphrase = KEYSTORE_PWD . toCharArray ( ) ; ks . load ( ksStream , passphrase ) ; kmf . init ( ks , passphrase ) ; ctx . init ( kmf . getKeyManagers ( ) , null , new java . security . SecureRandom ( ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new SSLException ( "Unable to initialize SSLSocketFactory" + e . getMessage ( ) , e ) ; } finally { streamManager . closeAll ( ) ; } return ctx . createSSLEngine ( ) ; }
Creates configures and returns the SSL engine .