If you need to support only HTTPS can be referenced
Release Notes
httpclinet:4.3.1
jdk:1.6
Tomcat:6
HTTPS Bidirectional authentication Reference article
8592331 according to the code written in this article will report the following error
Solutions
Refer to http://blog.51cto.com/2074199/2088928, then change the sslcontext to the following code
InputStream ksis = new FileInputStream(new File("client.p12的路径"));InputStream tsis = new FileInputStream(new File("server.jks的路径"));KeyStore ks = KeyStore.getInstance("PKCS12");ks.load(ksis, "storepass密码".toCharArray());KeyStore ts = KeyStore.getInstance("JKS");ts.load(tsis, "storepass密码".toCharArray());sslcontext = SSLContexts.custom().loadKeyMaterial(ks, "keypass".toCharArray()).loadTrustMaterial(ts, new TrustSelfSignedStrategy()).build();
The Loadkeymaterial () overload method is used to load the client certificate
The Loadtrustmaterial () overload method is used to load server-side related information (we use the new Trustselfsignedstrategy () method to implement a trust policy without verifying the server-side certificate)
HTTPS bidirectional authentication