Refine search
private static SSLContext getNonValidatingSslContext() { try { return new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); } catch (KeyManagementException e) { throw new RuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (KeyStoreException e) { throw new RuntimeException(e); } }
instream.close(); SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, passwd.toCharArray()).build();
/** * * @param maxTotal maxTotal * @param maxPerRoute maxPerRoute * @param timeout timeout * @param retryExecutionCount retryExecutionCount * @return CloseableHttpClient */ public static CloseableHttpClient createHttpClient(int maxTotal,int maxPerRoute,int timeout,int retryExecutionCount) { try { SSLContext sslContext = SSLContexts.custom().useSSL().build(); SSLConnectionSocketFactory sf = new SSLConnectionSocketFactory(sslContext,SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(); poolingHttpClientConnectionManager.setMaxTotal(maxTotal); poolingHttpClientConnectionManager.setDefaultMaxPerRoute(maxPerRoute); SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(timeout).build(); poolingHttpClientConnectionManager.setDefaultSocketConfig(socketConfig); return HttpClientBuilder.create() .setConnectionManager(poolingHttpClientConnectionManager) .setSSLSocketFactory(sf) .setRetryHandler(new HttpRequestRetryHandlerImpl(retryExecutionCount)) .build(); } catch (KeyManagementException e) { logger.error("", e); } catch (NoSuchAlgorithmException e) { logger.error("", e); } return null; }
SSLContext sslContext = SSLContexts.custom().useSSL().loadKeyMaterial(keystore, keyPassword.toCharArray()).build(); SSLConnectionSocketFactory sf = new SSLConnectionSocketFactory(sslContext,supportedProtocols, null,SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
public SSLSocketFactory( final KeyStore keystore, final String keystorePassword, final KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(SSLContexts.custom() .loadKeyMaterial(keystore, keystorePassword != null ? keystorePassword.toCharArray() : null) .loadTrustMaterial(truststore) .build(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); }
/** * @since 4.1 */ public SSLSocketFactory( final TrustStrategy trustStrategy, final X509HostnameVerifier hostnameVerifier) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(SSLContexts.custom() .loadTrustMaterial(null, trustStrategy) .build(), hostnameVerifier); }
private SSLContext createSslContext( final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { return SSLContexts.custom() .useProtocol(algorithm) .setSecureRandom(random) .loadKeyMaterial(keystore, keyPassword != null ? keyPassword.toCharArray() : null) .loadTrustMaterial(truststore) .build(); }
private SSLContext buildSslContext() { try { SSLContextBuilder contextBuilder = new SSLContextBuilder(). useTLS(). loadTrustMaterial(null, new TrustSelfSignedStrategy()); return contextBuilder.build(); } catch (GeneralSecurityException e) { throw new CloudOperationException(e); } } }
private javax.net.ssl.SSLContext buildSslContext() { try { return new SSLContextBuilder().useSSL().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); } catch (GeneralSecurityException gse) { throw new RuntimeException("An error occurred setting up the SSLContext", gse); } }
private SSLSocketFactory createSSLSocketFactory(boolean useKeyStoreToConnect, String keyStorePath, String keyStorePassword) throws Exception { //Only load KeyStore when it's needed to connect to IP, SSLContext is fine with KeyStore being null otherwise. KeyStore trustStore = null; if (useKeyStoreToConnect) { trustStore = KeyStoreLoader.loadKeyStore(keyStorePath, keyStorePassword); } SSLContext sslContext = SSLContexts.custom() .useSSL() .loadTrustMaterial(trustStore, new TrustStrategy() { //Always trust @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }) .loadKeyMaterial(trustStore, keyStorePassword.toCharArray()) .setSecureRandom(new java.security.SecureRandom()) .build(); return sslContext.getSocketFactory(); }
truststorePassword.toCharArray()); SSLContextBuilder sslContextBuilder = new SSLContextBuilder(); sslContextBuilder.loadTrustMaterial(truststore); keystorePassword.toCharArray()); sslContextBuilder.loadKeyMaterial(keystore, keypassword.toCharArray()); SSLContext sslContext = sslContextBuilder.build();
builder.setSslcontext(new SSLContextBuilder().useSSL().build());
/** * Creates custom SSL context. * * @return default system SSL context */ public static SSLContextBuilder custom() { return new SSLContextBuilder(); }
protected void createKeystore(SSLContextBuilder sslContextBuilder, boolean useClientCert) { if (useClientCert) { KeyStore clientKeyStore; try { clientKeyStore = createKeyStore(new URL(keystore), keystorePassword); sslContextBuilder.loadKeyMaterial(clientKeyStore, keystorePassword.toCharArray()); } catch (UnrecoverableKeyException | IOException ue) { throw new IllegalArgumentException(ue.getMessage() + ". " + BAD_KEYSTORE_ERROR, ue); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_KEYSTORE_ERROR, gse); } } }
public SSLSocketFactory( final KeyStore keystore, final String keystorePassword, final KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(SSLContexts.custom() .loadKeyMaterial(keystore, keystorePassword != null ? keystorePassword.toCharArray() : null) .loadTrustMaterial(truststore) .build(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); }
/** * @since 4.1 */ public SSLSocketFactory( final TrustStrategy trustStrategy, final X509HostnameVerifier hostnameVerifier) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(SSLContexts.custom() .loadTrustMaterial(null, trustStrategy) .build(), hostnameVerifier); }
public SSLSocketFactory( final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final HostNameResolver nameResolver) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(SSLContexts.custom() .useProtocol(algorithm) .setSecureRandom(random) .loadKeyMaterial(keystore, keyPassword != null ? keyPassword.toCharArray() : null) .loadTrustMaterial(truststore) .build(), nameResolver); }
private SSLContext buildSslContext() { try { SSLContextBuilder contextBuilder = new SSLContextBuilder().useTLS() .loadTrustMaterial(null, new TrustSelfSignedStrategy()); return contextBuilder.build(); } catch (GeneralSecurityException e) { throw new CloudException(e); } }
private javax.net.ssl.SSLContext buildSslContext() { try { return new SSLContextBuilder().useSSL() .loadTrustMaterial(null, new TrustSelfSignedStrategy()) .build(); } catch (GeneralSecurityException gse) { throw new RuntimeException("An error occurred setting up the SSLContext", gse); } }