List of usage examples for org.apache.http.conn.ssl SSLContexts createDefault
public static SSLContext createDefault() throws SSLInitializationException
cacerts
file in the security properties directory). From source file:com.leetchi.api.client.ssl.SSLConnectionSocketFactory.java
/** * Obtains default SSL socket factory with an SSL context based on the standard JSSE * trust material (<code>cacerts</code> file in the security properties directory). * System properties are not taken into consideration. * * @return default SSL socket factory//from w w w . j a v a 2 s .c o m */ public static SSLConnectionSocketFactory getSocketFactory() throws SSLInitializationException { return new SSLConnectionSocketFactory(SSLContexts.createDefault(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); }
From source file:microsoft.exchange.webservices.data.EwsSSLProtocolSocketFactory.java
public static EwsSSLProtocolSocketFactory build(TrustManager trustManager) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { SSLContext sslContext = SSLContexts.createDefault(); sslContext.init(null, new TrustManager[] { new EwsX509TrustManager(null, trustManager) }, null); return new EwsSSLProtocolSocketFactory(sslContext); }
From source file:org.olat.core.commons.services.webdav.WebDAVConnection.java
public WebDAVConnection(String protocol, String host, int port) { this.protocol = protocol; this.host = host; this.port = port; SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(SSLContexts.createDefault(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); httpclient = HttpClientBuilder.create().setDefaultCookieStore(cookieStore) .setDefaultCredentialsProvider(provider).setSSLSocketFactory(sslFactory).build(); }
From source file:co.paralleluniverse.fibers.dropwizard.FiberHttpClientBuilder.java
private static Registry<SchemeIOSessionStrategy> convertRegistry(final SchemeRegistry oldRegistry) throws SSLInitializationException { SchemeRegistry baseRegistry = oldRegistry; //TODO: use values from old registry; Registry<SchemeIOSessionStrategy> defaultRegistry = RegistryBuilder.<SchemeIOSessionStrategy>create() .register("http", NoopIOSessionStrategy.INSTANCE) .register("https", new SSLIOSessionStrategy(SSLContexts.createDefault(), null, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER)) .build();/* w w w . jav a2s.co m*/ return defaultRegistry; }
From source file:org.glassfish.jersey.apache.connector.ApacheConnector.java
private HttpClientConnectionManager createConnectionManager(final Client client, final Configuration config, final SSLContext sslContext, final boolean useSystemProperties) { final String[] supportedProtocols = useSystemProperties ? split(System.getProperty("https.protocols")) : null;/*ww w. j a v a 2 s .co m*/ final String[] supportedCipherSuites = useSystemProperties ? split(System.getProperty("https.cipherSuites")) : null; HostnameVerifier hostnameVerifier = client.getHostnameVerifier(); final LayeredConnectionSocketFactory sslSocketFactory; if (sslContext != null) { sslSocketFactory = new SSLConnectionSocketFactory(sslContext, supportedProtocols, supportedCipherSuites, hostnameVerifier); } else { if (useSystemProperties) { sslSocketFactory = new SSLConnectionSocketFactory((SSLSocketFactory) SSLSocketFactory.getDefault(), supportedProtocols, supportedCipherSuites, hostnameVerifier); } else { sslSocketFactory = new SSLConnectionSocketFactory(SSLContexts.createDefault(), hostnameVerifier); } } final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslSocketFactory).build(); final Integer chunkSize = ClientProperties.getValue(config.getProperties(), ClientProperties.CHUNKED_ENCODING_SIZE, ClientProperties.DEFAULT_CHUNK_SIZE, Integer.class); final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( registry, new ConnectionFactory(chunkSize)); if (useSystemProperties) { String s = System.getProperty("http.keepAlive", "true"); if ("true".equalsIgnoreCase(s)) { s = System.getProperty("http.maxConnections", "5"); final int max = Integer.parseInt(s); connectionManager.setDefaultMaxPerRoute(max); connectionManager.setMaxTotal(2 * max); } } return connectionManager; }
From source file:com.github.dockerjava.jaxrs.connector.ApacheConnector.java
private HttpClientConnectionManager createConnectionManager(final Configuration config, final SSLContext sslContext, X509HostnameVerifier hostnameVerifier, final boolean useSystemProperties) { final String[] supportedProtocols = useSystemProperties ? split(System.getProperty("https.protocols")) : null;// www. j a v a2 s . c o m final String[] supportedCipherSuites = useSystemProperties ? split(System.getProperty("https.cipherSuites")) : null; if (hostnameVerifier == null) { hostnameVerifier = SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER; } final LayeredConnectionSocketFactory sslSocketFactory; if (sslContext != null) { sslSocketFactory = new SSLConnectionSocketFactory(sslContext, supportedProtocols, supportedCipherSuites, hostnameVerifier); } else { if (useSystemProperties) { sslSocketFactory = new SSLConnectionSocketFactory((SSLSocketFactory) SSLSocketFactory.getDefault(), supportedProtocols, supportedCipherSuites, hostnameVerifier); } else { sslSocketFactory = new SSLConnectionSocketFactory(SSLContexts.createDefault(), hostnameVerifier); } } final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslSocketFactory).build(); final Integer chunkSize = ClientProperties.getValue(config.getProperties(), ClientProperties.CHUNKED_ENCODING_SIZE, 4096, Integer.class); final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( registry, new ConnectionFactory(chunkSize)); if (useSystemProperties) { String s = System.getProperty("http.keepAlive", "true"); if ("true".equalsIgnoreCase(s)) { s = System.getProperty("http.maxConnections", "5"); final int max = Integer.parseInt(s); connectionManager.setDefaultMaxPerRoute(max); connectionManager.setMaxTotal(2 * max); } } return connectionManager; }