/** * Disable SSL and hostname verification for given HTTP connection * * @param conn * a {@link org.eclipse.jgit.transport.http.HttpConnection} * object. * @throws java.io.IOException * @since 4.3 */ public static void disableSslVerify(HttpConnection conn) throws IOException { final TrustManager[] trustAllCerts = new TrustManager[] { new DummyX509TrustManager() }; try { conn.configure(null, trustAllCerts, null); conn.setHostnameVerifier(new DummyHostnameVerifier()); } catch (KeyManagementException e) { throw new IOException(e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new IOException(e.getMessage()); } }
@Nonnull protected HttpConnection configure(@Nonnull HttpConnection input) throws IOException { try { final KeyStore keyStore = loadKeyStore(); final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); final TrustManager[] defaultTrustManagers = trustManagerFactory.getTrustManagers(); final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, null); final KeyManager[] keyManagers = keyManagerFactory.getKeyManagers(); input.configure(keyManagers, defaultTrustManagers, null); input.setInstanceFollowRedirects(true); return input; } catch (final GeneralSecurityException e) { throw new IOException(e.getMessage(), e); } }
@Nonnull protected HttpConnection configure(@Nonnull HttpConnection input) throws IOException { try { final KeyStore keyStore = loadKeyStore(); final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); final TrustManager[] defaultTrustManagers = trustManagerFactory.getTrustManagers(); final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, null); final KeyManager[] keyManagers = keyManagerFactory.getKeyManagers(); input.configure(keyManagers, defaultTrustManagers, null); input.setInstanceFollowRedirects(true); return input; } catch (final GeneralSecurityException e) { throw new IOException(e.getMessage(), e); } }
/** * Disable SSL and hostname verification for given HTTP connection * * @param conn * a {@link org.eclipse.jgit.transport.http.HttpConnection} * object. * @throws java.io.IOException * @since 4.3 */ public static void disableSslVerify(HttpConnection conn) throws IOException { final TrustManager[] trustAllCerts = new TrustManager[] { new DummyX509TrustManager() }; try { conn.configure(null, trustAllCerts, null); conn.setHostnameVerifier(new DummyHostnameVerifier()); } catch (KeyManagementException e) { throw new IOException(e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new IOException(e.getMessage()); } }
/** * Disable SSL and hostname verification for given HTTP connection * * @param conn * @throws IOException * @since 4.3 */ public static void disableSslVerify(HttpConnection conn) throws IOException { final TrustManager[] trustAllCerts = new TrustManager[] { new DummyX509TrustManager() }; try { conn.configure(null, trustAllCerts, null); conn.setHostnameVerifier(new DummyHostnameVerifier()); } catch (KeyManagementException e) { throw new IOException(e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new IOException(e.getMessage()); } }