开发者

Trustore with certificates for several hosts

开发者 https://www.devze.com 2023-02-08 06:41 出处:网络
I do have a working demo with an applet connecting to a server (\"A\") through https. The server\'s certificates chain is loaded by the applet via a JKS truststore ( myTrustManagerFactory.init(mytrust

I do have a working demo with an applet connecting to a server ("A") through https. The server's certificates chain is loaded by the applet via a JKS truststore ( myTrustManagerFactory.init(mytrustStore.jks) ). It works fine.

Now I need this applet to connect to another server ("B") through https too. The server's certificate is signed by a self-signed CA. So I need to pass this self-signed CA to the applet TrustManagerFactory.

  • Can I put it in the same JKS trustore than the one used f开发者_JAVA技巧or server "A"? If so, do I have to save this self-signed CA using a second alias? I tried that but I get errors when connecting to server "B". Is there a way to specify the server "B" alias to the TrustManagerFactory?

  • Should I use a second JKS, or some SSL context "reset" before to call the 2nd server?

Thanks for your help,

Rodolphe


just found the solution by myself:
The error message "Certificate chaining error" does not reflect a chain problem in the Truststore but rather a chain problem in the server.

So, in case it might help, it is OK to load in a Truststore several (chain of) certificates to trust several servers in https. Just need one alias per server (the alias name does not matter), and the (chain of) certificates needed to trust this server.

No need to reset anything when switching communication to another server. Just load all chains of certificates of the servers in a single "myTrustManagerFactory.init(mytrustStore.jks)" method.

0

精彩评论

暂无评论...
验证码 换一张
取 消