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?
It’s a
org.apache.http.conn.ssl.SSLSocketFactoryyou should use, not ajavax.net.ssl.SSLSocketFactory(seeimportdirective 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.SSLSocketFactoryfrom anSSLContext, so you might as well use theSSLContext-based constructor in this case.