Per the example at http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientCustomSSL.java
SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
Should instantiate a SSLSocketFactory using my custom trust store, yet when I try to build my project, I get the error
javax.net.ssl.SSLSocketFactory is abstract; cannot be intantiated
Is the example out of date? Does it work for other people?
SSLSocketFactory acts as a factory for creating secure sockets. This class is an abstract subclass of javax. net. SocketFactory . Secure socket factories encapsulate the details of creating and initially configuring secure sockets.
SSLConnectionSocketFactory is a layered socket factory for TSL and SSL connections. Using this, you can verify the Https server using a list of trusted certificates and authenticate the given Https server. You can create this in many ways.
The TrustSelfSignedStrategy works as follows: @Override public boolean isTrusted( final X509Certificate[] chain, final String authType) throws CertificateException { return chain.length == 1; } A self singed certificate is issued by the target of the certificate.
A strategy to establish trustworthiness of certificates without consulting the trust manager configured in the actual SSL context. This interface can be used to override the standard JSSE certificate verification process.
It's a org.apache.http.conn.ssl.SSLSocketFactory
you should use, not a javax.net.ssl.SSLSocketFactory
(see import
directive in the example file you're using).
Note that the former has constructors that can use the latter if you already have existing code for this. However, you would generally get a custom javax.net.ssl.SSLSocketFactory
from an SSLContext
, so you might as well use the SSLContext
-based constructor in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With