@Inject SSLContextWithKeysSupplier(Supplier<FGCPCredentials> creds, HttpUtils utils, TrustAllCerts trustAllCerts) { this.creds = creds; this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; }
@Inject SSLContextWithKeysSupplier(Supplier<FGCPCredentials> creds, HttpUtils utils, TrustAllCerts trustAllCerts) { this.creds = creds; this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; }
@Singleton @Provides SSLContext newSSLSocketFactory(HttpUtils utils, @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider) throws NoSuchAlgorithmException, KeyManagementException { if (utils.trustAllCerts()) return untrustedSSLContextProvider.get(); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); return context; }
@Singleton @Provides final SSLContext newSSLContext(HttpUtils utils, @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider) throws NoSuchAlgorithmException, KeyManagementException { if (utils.trustAllCerts()) return untrustedSSLContextProvider.get(); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); return context; }
@Singleton @Provides SSLContext newSSLSocketFactory(HttpUtils utils, @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider) throws NoSuchAlgorithmException, KeyManagementException { if (utils.trustAllCerts()) return untrustedSSLContextProvider.get(); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); return context; }
@Singleton @Provides final SSLContext newSSLContext(HttpUtils utils, @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider) throws NoSuchAlgorithmException, KeyManagementException { if (utils.trustAllCerts()) return untrustedSSLContextProvider.get(); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); return context; }
@Inject DelegatingSSLContextSupplier( Crypto crypto, @Provider Supplier<Credentials> creds, HttpUtils utils, TrustAllCerts trustAllCerts) { this.crypto = crypto; this.trustManager = utils.trustAllCerts() ? new TrustManager[]{trustAllCerts} : null; this.creds = creds; }
@Inject SSLContextWithKeysSupplier(Supplier<KeyStore> keyStore, @Provider Supplier<Credentials> creds, HttpUtils utils, TrustAllCerts trustAllCerts) { this.keyStore = keyStore; this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; this.creds = creds; }
/** * Creates and initializes the connection. */ protected HttpURLConnection initConnection(HttpRequest request) throws IOException { URL url = request.getEndpoint().toURL(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxyForURI.apply(request.getEndpoint())); if (connection instanceof HttpsURLConnection) { HttpsURLConnection sslCon = (HttpsURLConnection) connection; if (utils.relaxHostname()) sslCon.setHostnameVerifier(verifier); if (sslContextSupplier != null) { // used for providers which e.g. use certs for authentication (like FGCP) // Provider provides SSLContext impl (which inits context with key manager) sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory()); } else if (utils.trustAllCerts()) { sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); } } return connection; }
/** * Creates and initializes the connection. */ protected HttpURLConnection initConnection(HttpRequest request) throws IOException { URL url = request.getEndpoint().toURL(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxyForURI.apply(request.getEndpoint())); if (connection instanceof HttpsURLConnection) { HttpsURLConnection sslCon = (HttpsURLConnection) connection; if (utils.relaxHostname()) sslCon.setHostnameVerifier(verifier); if (sslContextSupplier != null) { // used for providers which e.g. use certs for authentication (like FGCP) // Provider provides SSLContext impl (which inits context with key manager) sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory()); } else if (utils.trustAllCerts()) { sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); } } return connection; }
/** * Creates and initializes the connection. */ protected HttpURLConnection initConnection(HttpRequest request) throws IOException { URL url = request.getEndpoint().toURL(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxyForURI.apply(request.getEndpoint())); if (connection instanceof HttpsURLConnection) { HttpsURLConnection sslCon = (HttpsURLConnection) connection; if (utils.relaxHostname()) sslCon.setHostnameVerifier(verifier); if (sslContextSupplier != null) { // used for providers which e.g. use certs for authentication (like FGCP) // Provider provides SSLContext impl (which inits context with key manager) sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory()); } else if (utils.trustAllCerts()) { sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); } } return connection; }
/** * Creates and initializes the connection. */ protected HttpURLConnection initConnection(HttpRequest request) throws IOException { URL url = request.getEndpoint().toURL(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxyForURI.apply(request.getEndpoint())); if (connection instanceof HttpsURLConnection) { HttpsURLConnection sslCon = (HttpsURLConnection) connection; if (utils.relaxHostname()) sslCon.setHostnameVerifier(verifier); if (sslContextSupplier != null) { // used for providers which e.g. use certs for authentication (like FGCP) // Provider provides SSLContext impl (which inits context with key manager) sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory()); } else if (utils.trustAllCerts()) { sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); } } return connection; }
} else if (utils.trustAllCerts()) { sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory());
} else if (utils.trustAllCerts()) { sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory());
@Override public OkHttpClient get() { OkHttpClient client = clientSupplier.get(); client.setConnectTimeout(utils.getConnectionTimeout(), TimeUnit.MILLISECONDS); client.setReadTimeout(utils.getSocketOpenTimeout(), TimeUnit.MILLISECONDS); // do not follow redirects since https redirects don't work properly // ex. Caused by: java.io.IOException: HTTPS hostname wrong: should be // <adriancole.s3int0.s3-external-3.amazonaws.com> client.setFollowRedirects(false); if (utils.relaxHostname()) { client.setHostnameVerifier(verifier); } if (utils.trustAllCerts()) { client.setSslSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); } return client; } }
if (utils.relaxHostname() || utils.trustAllCerts()) options.doNotFollowRedirects(); options.setDeadline(10.0);
if (utils.relaxHostname() || utils.trustAllCerts()) options.doNotFollowRedirects(); options.setDeadline(10.0);