List of usage examples for java.security InvalidAlgorithmParameterException InvalidAlgorithmParameterException
public InvalidAlgorithmParameterException(String message, Throwable cause)
From source file:net.vexelon.myglob.utils.TrustAllSocketFactory.java
public TrustAllSocketFactory() throws InvalidAlgorithmParameterException { super();//from w w w .ja va 2 s . c o m TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[] {}; } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { } } }; SecureRandom secureRND = new SecureRandom(); try { sslContext = SSLContext.getInstance(org.apache.http.conn.ssl.SSLSocketFactory.TLS); sslContext.init(null, trustAllCerts, secureRND); } catch (NoSuchAlgorithmException e) { throw new InvalidAlgorithmParameterException("Failed to initlize TLS context!", e); } catch (KeyManagementException e) { throw new InvalidAlgorithmParameterException("Failed to init SSL context!", e); } socketFactory = sslContext.getSocketFactory(); }