private X509TrustManager createPromptingTrustManager ( ) { TrustManager [ ] trustManagers = null ; try { String defaultAlg = TrustManagerFactory . getDefaultAlgorithm ( ) ; TrustManagerFactory tmf = TrustManagerFactory . getInstance ( defaultAlg ) ; tmf . init ( ( KeyStore ) null ) ; trustManagers = tmf . getTrustManagers ( ) ; } catch ( KeyStoreException e ) { // Unable to initialize the default trust managers. // This is not a problem as PromptX509rustManager can handle null. } catch ( NoSuchAlgorithmException e ) { // Unable to get default trust managers. // This is not a problem as PromptX509rustManager can handle null. } boolean autoAccept = Boolean . valueOf ( System . getProperty ( SYS_PROP_AUTO_ACCEPT , "false" ) ) ; return new PromptX509TrustManager ( stdin , stdout , trustManagers , autoAccept ) ; }
Create a custom trust manager which will prompt for trust acceptance .