Java client certificates over HTTPS/SSL

后端 未结 8 928
攒了一身酷
攒了一身酷 2020-11-22 13:46

I am using Java 6 and am trying to create an HttpsURLConnection against a remote server, using a client certificate.
The server is using an selfsigned root

8条回答
  •  太阳男子
    2020-11-22 14:26

    Using below code

    -Djavax.net.ssl.keyStoreType=pkcs12
    

    or

    System.setProperty("javax.net.ssl.keyStore", pathToKeyStore);
    

    is not at all required. Also there is no need to create your own custom SSL factory.

    I also encountered the same issue, in my case there was a issue that complete certificate chain was not imported into truststores. Import certificates using keytool utility right fom root certificate, also you can open cacerts file in notepad and see if the complete certificate chain is imported or not. Check against the alias name you have provided while importing certificates, open the certificates and see how many does it contains, same number of certificates should be there in cacerts file.

    Also cacerts file should be configured in the server you are running your application, the two servers will authenticate each other with public/private keys.

提交回复
热议问题