org.apache.commons.httpclient.contrib.ssl
Class EasySSLProtocolSocketFactory
java.lang.Object
javax.net.SocketFactory
javax.net.ssl.SSLSocketFactory
org.apache.commons.ssl.SSLClient
org.apache.commons.ssl.HttpSecureProtocol
org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory
- All Implemented Interfaces:
- org.apache.commons.httpclient.protocol.ProtocolSocketFactory, org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
public class EasySSLProtocolSocketFactory
- extends HttpSecureProtocol
EasySSLProtocolSocketFactory can be used to creats 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 concious 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);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("localhost", 443, easyhttps);
// use relative url only
GetMethod httpget = new GetMethod("/");
client.executeMethod(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);
- Author:
- Oleg Kalnichevski
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.
Methods inherited from class org.apache.commons.ssl.SSLClient |
addTrustMaterial, createSocket, createSocket, createSocket, createSocket, createSocket, createSocket, createSocket, getAssociatedCertificateChain, getCheckCRL, getCheckExpiry, getCheckHostname, getConnectTimeout, getCurrentServerChain, getDefaultCipherSuites, getDefaultProtocol, getEnabledCiphers, getEnabledProtocols, getHostnameVerifier, getNeedClientAuth, getSoTimeout, getSSLContext, getSSLWrapperFactory, getSupportedCipherSuites, getTrustChain, getUseClientMode, getWantClientAuth, isSecure, setCheckCRL, setCheckExpiry, setCheckHostname, setConnectTimeout, setDefaultProtocol, setDnsOverride, setEnabledCiphers, setEnabledProtocols, setHostnameVerifier, setIsSecure, setKeyMaterial, setNeedClientAuth, setSoTimeout, setSSLWrapperFactory, setTrustMaterial, setUseClientMode, setWantClientAuth, useDefaultJavaCiphers, useStrongCiphers |
Methods inherited from class javax.net.ssl.SSLSocketFactory |
getDefault |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory |
createSocket |
Methods inherited from interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory |
createSocket, createSocket |
EasySSLProtocolSocketFactory
public EasySSLProtocolSocketFactory()
throws java.security.GeneralSecurityException,
java.io.IOException
- Constructor for EasySSLProtocolSocketFactory.
- Throws:
java.security.GeneralSecurityException
- GeneralSecurityException
java.io.IOException
- IOException