Java – trustore with multiple host certificates

I have a working demo where the applet connects to the server ("a") via HTTPS The certificate chain of the server is loaded by the applet through the JKS trust store (mytrustmanagerfactory. Init (mytruststore. JKS)) It works normally

Now I need this applet to connect to another server ("B") via HTTPS The server's certificate is signed by a self - signed ca So I need to pass this self signed CA to applet trustmanagerfactory

>Can I put it in the same JKS trust as server "a"? If so, do I have to save this self signed CA with a second alias? I tried, but there was an error connecting to server "B" Is there any way to specify the server "B" alias for trustmanagerfactory? > Should I use a second JKS or some SSL context to "reset" before calling the second server?

Thank you for your help, Rudolph

Solution

I found the solution myself:

Therefore, if it may be helpful, you can load several (chain) certificates in the truststore to trust multiple servers in HTTPS Each server only needs an alias (the alias doesn't matter) and the (chain) certificate required to trust the server

There is no need to reset anything when switching communication with other servers Just load all certificate chains of the server in a single "mytrustmanagerfactory. Init (mytruststore. JKS)" method

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>