> private void setDefaultTrustManager()
> {
> - trustManagers = new X509TrustManager[] { new
> NoVerificationTrustManager() };
> + String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
> +
> + try
> + {
> + TrustManagerFactory tmf = TrustManagerFactory.getInstance(
> defaultAlgorithm );
> + tmf.init( ( KeyStore ) null );
> + trustManagers = tmf.getTrustManagers();
> + }
> + catch ( KeyStoreException kse )
> + {
> + LOG.error( I18n.err( I18n.ERR_04172_KEYSTORE_INIT_FAILURE ) );
> + }
> + catch ( NoSuchAlgorithmException nsae )
> + {
> + LOG.error( I18n.err( I18n.ERR_04173_ALGORITHM_NOT_FOUND,
> defaultAlgorithm ) );
> + }
> }
Thanks Emmanuel for fixing this.
I'd like to suggest one improvement: In case of those two exceptions
let's rethrow them (wrapped into a RuntimeException). I know those
should not happen, but just in case I think it's better to crash than
continue with none.
Kind Regards,
Stefan