http://jakarta.apache.org/commons/httpclient/sslguide.html
Here's a EasySSLProtocolSocketFactory that works with JDK1.4
Your source doesn't work because of some dependencies on com.sun.* classes. It's mainly the getSocketFactory-method that was changed.
import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager;
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
public class SSLProtocolSocketFactory implements SecureProtocolSocketFactory
{
private static class TM implements X509TrustManager
{
public X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[0];
}public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
{
}
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
{
}
}
private static SSLSocketFactory getSocketFactory()
{
try
{
SSLContext context = SSLContext.getInstance("SSL");
context.init(null, new TrustManager[] {new TM()}, null);
return context.getSocketFactory();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}public Socket createSocket(String host, int port, InetAddress clientHost,
int clientPort) throws IOException, UnknownHostException
{
return getSocketFactory().createSocket(host, port, clientHost, clientPort);
}
public Socket createSocket(String host, int port)
throws IOException, UnknownHostException
{
return getSocketFactory().createSocket(host, port);
}public Socket createSocket(Socket socket, String host, int port,
boolean autoClose) throws IOException, UnknownHostException
{
return getSocketFactory().createSocket(socket, host, port, autoClose);
}
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
