I try to connect to a server with a self-signed certificate. I use this code to accept all certificates.
public class CertificateAcceptor {
public void
The Answer by Prashant may not work, as you need to initialize the SSLContext
as well.
I would do it something like,
SSLSocketFactory sf=null ;
SSLContext sslContext = null;
StringWriter writer;
try {
sslContext = SSLContext.getInstance("TLS") ;
sslContext.init(null,null,null);
} catch (NoSuchAlgorithmException e) {
//
} catch (KeyManagementException e){
//
}
try{
sf = new SSLSocketFactory(sslContext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch(Exception e) {
//
}
Scheme scheme = new Scheme("https",443,sf);
httpClient.getConnectionManager().getSchemeRegistry().register(scheme);