HTTPS bidirectional authentication

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.