List of usage examples for javax.net.ssl X509TrustManager X509TrustManager
X509TrustManager
From source file:org.owasp.goatdroid.herdfinancial.requestresponse.CustomSSLSocketFactory.java
public CustomSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm = new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; }/*from w w w . j a va 2 s .c o m*/ @Override public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException { // TODO Auto-generated method stub } @Override public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException { // TODO Auto-generated method stub } }; sslContext.init(null, new TrustManager[] { tm }, null); }
From source file:com.cloud.network.bigswitch.TrustingProtocolSocketFactory.java
public TrustingProtocolSocketFactory() throws IOException { // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override//w ww .j a v a 2 s . com public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { // Trust always } @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { // Trust always } } }; try { // Install the all-trusting trust manager SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); ssf = sc.getSocketFactory(); } catch (KeyManagementException e) { throw new IOException(e); } catch (NoSuchAlgorithmException e) { throw new IOException(e); } }
From source file:to.sparks.mtgox.net.HTTPAuthenticator.java
public HTTPAuthenticator(final Logger logger, String apiKey, String secret) { this.apiKey = apiKey; this.secret = secret; TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override/*from ww w . jav a 2 s . c o 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()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception e) { logger.log(Level.SEVERE, null, e); } }
From source file:com.wso2telco.gsma.shorten.SSLSocket.java
/** * Instantiates a new SSL socket.//w ww.java 2 s .c o m * * @param truststore the truststore * @throws NoSuchAlgorithmException the no such algorithm exception * @throws KeyManagementException the key management exception * @throws KeyStoreException the key store exception * @throws UnrecoverableKeyException the unrecoverable key exception */ public SSLSocket(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers() { return null; } }; sslContext.init(null, new TrustManager[] { tm }, null); }
From source file:org.xapek.zs.InsecureSSLProtocolSocketFactory.java
/** * Creates a new insecure SSL protocol socket factory. * * @throws GeneralSecurityException/* w ww . j a v a 2s. c o m*/ * if a security error occurs */ public InsecureSSLProtocolSocketFactory() throws GeneralSecurityException { context_ = SSLContext.getInstance("SSL"); context_.init(null, new TrustManager[] { new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } } }, null); }
From source file:nz.net.catalyst.MaharaDroid.upload.http.DebugSSLSocketFactory.java
public DebugSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { }/* w w w . j a v a 2 s. c o m*/ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers() { return null; } }; sslContext.init(null, new TrustManager[] { tm }, null); }
From source file:com.groupon.odo.tests.HttpUtils.java
public static String doProxyHttpsGet(String url, BasicNameValuePair[] data) throws Exception { String fullUrl = url;/*from w w w.j a v a 2 s . co m*/ if (data != null) { if (data.length > 0) { fullUrl += "?"; } for (BasicNameValuePair bnvp : data) { fullUrl += bnvp.getName() + "=" + uriEncode(bnvp.getValue()) + "&"; } } TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception e) { } URL uri = new URL(fullUrl); int port = Utils.getSystemPort(Constants.SYS_FWD_PORT); Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", port)); URLConnection connection = uri.openConnection(proxy); BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream())); String accumulator = ""; String line = ""; Boolean firstLine = true; while ((line = rd.readLine()) != null) { accumulator += line; if (!firstLine) { accumulator += "\n"; } else { firstLine = false; } } return accumulator; }
From source file:com.trsst.client.AnonymSSLSocketFactory.java
/** * Create the SSL Context./*w ww. j a v a 2 s . c o m*/ * * @return The SSLContext */ private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); //$NON-NLS-1$ context.init(null, new TrustManager[] { new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServerTrusted(X509Certificate[] chain, String authType) { } public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[] {}; } } }, null); return context; } catch (Exception e) { throw new HttpClientError(e.toString()); } }
From source file:cn.keke.travelmix.EasySSLSocketFactory.java
public EasySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(TLS, null, null, truststore, null, null, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { // skip }/*from www .j av a 2 s.c o m*/ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { // skip } public X509Certificate[] getAcceptedIssuers() { return null; } }; this.sslContext.init(null, new TrustManager[] { tm }, null); }
From source file:it_minds.dk.eindberetningmobil_android.server.DebugOkHttpStack.java
private static OkHttpClient getUnsafeOkHttpClient(OkHttpClient client) { try {//from w ww. j a v a 2 s.c o m // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { } @Override public java.security.cert.X509Certificate[] getAcceptedIssuers() { return new java.security.cert.X509Certificate[] {}; } } }; // Install the all-trusting trust manager final SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); // Create an ssl socket factory with our all-trusting manager final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); client.setSslSocketFactory(sslSocketFactory); client.setHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }); return client; } catch (Exception e) { throw new RuntimeException(e); } }