public class SelfSignedCertificateAcceptingSocketFactory
extends java.lang.Object
implements org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
EasySSLProtocolSocketFactory can be used to creats SSL Sockets
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);
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);
| Constructor and Description |
|---|
SelfSignedCertificateAcceptingSocketFactory() |
| Modifier and Type | Method and Description |
|---|---|
java.net.Socket |
createSocket(java.net.Socket socket,
java.lang.String host,
int port,
boolean autoClose) |
java.net.Socket |
createSocket(java.lang.String host,
int port) |
java.net.Socket |
createSocket(java.lang.String host,
int port,
java.net.InetAddress localHost,
int localPort) |
java.net.Socket |
createSocket(java.lang.String host,
int port,
java.net.InetAddress localAddress,
int localPort,
org.apache.commons.httpclient.params.HttpConnectionParams params) |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
public SelfSignedCertificateAcceptingSocketFactory()
public java.net.Socket createSocket(java.lang.String host,
int port,
java.net.InetAddress localHost,
int localPort)
throws java.io.IOException
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactoryjava.io.IOExceptionpublic java.net.Socket createSocket(java.lang.String host,
int port,
java.net.InetAddress localAddress,
int localPort,
org.apache.commons.httpclient.params.HttpConnectionParams params)
throws java.io.IOException
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactoryjava.io.IOExceptionpublic java.net.Socket createSocket(java.lang.String host,
int port)
throws java.io.IOException
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactoryjava.io.IOExceptionpublic java.net.Socket createSocket(java.net.Socket socket,
java.lang.String host,
int port,
boolean autoClose)
throws java.io.IOException
createSocket in interface org.apache.commons.httpclient.protocol.SecureProtocolSocketFactoryjava.io.IOExceptionpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object