public class EwsSSLProtocolSocketFactory extends org.apache.http.conn.ssl.SSLConnectionSocketFactory
EwsSSLProtocolSocketFactory can be used to create SSL Socket
s
that accept self-signed certificates.
This socket factory SHOULD NOT be used for productive systems due to security reasons, unless it is a conscious decision and you are perfectly aware of security implications of accepting self-signed certificates
Example of using custom protocol socket factory for a specific host:Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443); URI uri = new URI("https://localhost/", true); // use relative url only GetMethod httpget = new GetMethod(uri.getPathQuery()); HostConfiguration hc = new HostConfiguration(); hc.setHost(uri.getHost(), uri.getPort(), easyhttps); HttpClient client = new HttpClient(); client.executeMethod(hc, httpget);
Example of using custom protocol socket factory per default instead of the standard one:
Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443); Protocol.registerProtocol("https", easyhttps); HttpClient client = new HttpClient(); GetMethod httpget = new GetMethod("https://localhost/"); client.executeMethod(httpget);
DISCLAIMER: HttpClient developers DO NOT actively support this component. The component is provided as a reference material, which may be inappropriate for use without additional customization.
Constructor and Description |
---|
EwsSSLProtocolSocketFactory(SSLContext context,
HostnameVerifier hostnameVerifier)
Constructor for EasySSLProtocolSocketFactory.
|
Modifier and Type | Method and Description |
---|---|
static EwsSSLProtocolSocketFactory |
build(TrustManager trustManager)
Create and configure SSL protocol socket factory using default hostname verifier.
|
static EwsSSLProtocolSocketFactory |
build(TrustManager trustManager,
HostnameVerifier hostnameVerifier)
Create and configure SSL protocol socket factory using trust manager and hostname verifier.
|
static SSLContext |
createSslContext(TrustManager trustManager)
Create SSL context and initialize it using specific trust manager.
|
boolean |
equals(Object obj) |
SSLContext |
getContext() |
int |
hashCode() |
public EwsSSLProtocolSocketFactory(SSLContext context, HostnameVerifier hostnameVerifier)
context
- SSL contexthostnameVerifier
- hostname verifierpublic static EwsSSLProtocolSocketFactory build(TrustManager trustManager) throws GeneralSecurityException
DEFAULT_HOSTNAME_VERIFIER
trustManager
- trust managerGeneralSecurityException
- on security errorpublic static EwsSSLProtocolSocketFactory build(TrustManager trustManager, HostnameVerifier hostnameVerifier) throws GeneralSecurityException
trustManager
- trust managerhostnameVerifier
- hostname verifierGeneralSecurityException
- on security errorpublic static SSLContext createSslContext(TrustManager trustManager) throws GeneralSecurityException
trustManager
- trust managerGeneralSecurityException
- on security errorpublic SSLContext getContext()
Copyright © 2012–2015 Microsoft. All rights reserved.