List of usage examples for javax.net.ssl X509TrustManager X509TrustManager
X509TrustManager
From source file:org.mifos.tools.provider.RestAdapterProvider.java
private OkHttpClient createClient() { final OkHttpClient client = new OkHttpClient(); final TrustManager[] certs = new TrustManager[] { new X509TrustManager() { @Override// w w w .j a v a 2 s . c o m public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { } @Override public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { } } }; SSLContext ctx = null; try { ctx = SSLContext.getInstance("TLS"); ctx.init(null, certs, new SecureRandom()); } catch (final java.security.GeneralSecurityException ex) { // do nothing, ignore } try { final HostnameVerifier hostnameVerifier = new HostnameVerifier() { @Override public boolean verify(final String hostname, final SSLSession session) { return true; } }; client.setHostnameVerifier(hostnameVerifier); client.setSslSocketFactory(ctx.getSocketFactory()); } catch (final Exception e) { // do nothing, ignore } return client; }
From source file:gov.nist.appvet.servlet.shared.SSLWrapper.java
@SuppressWarnings("deprecation") public synchronized static HttpClient wrapClient(HttpClient base) { SSLContext ctx = null;/* ww w . j ava 2 s .com*/ X509TrustManager tm = null; SSLSocketFactory ssf = null; SchemeRegistry sr = null; try { ctx = SSLContext.getInstance("TLSv1.2"); tm = new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; ctx.init(null, new TrustManager[] { tm }, null); ssf = new SSLSocketFactory(ctx); ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); final ClientConnectionManager ccm = base.getConnectionManager(); sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", 443, ssf)); return new DefaultHttpClient(ccm, base.getParams()); } catch (final Exception e) { log.error(e.getMessage().toString()); return null; } finally { sr = null; ssf = null; tm = null; ctx = null; } }
From source file:com.dolphin.browser.Network.EasySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {/*from w ww .j a va 2 s.c o m*/ SSLContext context = HttpRequester.createSSLConext(); context.init(null, new TrustManager[] { new X509TrustManager() { @Override public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } } }, null); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:och.util.NetUtil.java
private static SSLSocketFactory getTrustAllSocketFactory() { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override/*from w w w .j a v a 2 s . co m*/ public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); return sc.getSocketFactory(); } catch (Exception e) { log.error("can't create trustAllSocketFactory", e); return null; } }
From source file:com.codesharp.cooper.plugins.EasySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {/*from ww w .j ava 2 s .c o m*/ SSLContext context = SSLContext.getInstance("TLS"); // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { // do nothing } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { // do nothing } } }; context.init(null, trustAllCerts, new SecureRandom()); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:com.framework.library.connection.EasySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {//from w ww .j a va 2 s . c om SSLContext context = SSLContext.getInstance("TLS"); // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { // do nothing } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { // do nothing } } }; context.init(null, trustAllCerts, new SecureRandom()); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:com.dealoka.lib.net.EasySSLSocketFactory.java
public EasySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { }//from w w w . j av a 2s .com public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers() { return null; } }; sslContext.init(null, new TrustManager[] { tm }, null); }
From source file:de.gfred.lbbms.mobile.services.IgnoreSelfCertificatesSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {// w ww. j av a2 s .c o m SSLContext context = SSLContext.getInstance("TLS"); // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { // do nothing } public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { // do nothing } } }; context.init(null, trustAllCerts, new SecureRandom()); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:com.cloupia.feature.nimble.http.MySSLSocketFactory.java
private TrustManager[] getTrustManager() { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; }/*from ww w. j av a 2 s.c o m*/ public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) { } } }; return trustAllCerts; }
From source file:org.jssec.android.https.vulnerables.VulnerableSamples.java
public void emptyTrustManager() throws IOException, KeyManagementException, NoSuchAlgorithmException { TrustManager tm = new X509TrustManager() { @Override/*from www . j a v a2 s. co m*/ public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { // ??? ????? } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { // ??? ????? } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; }