有没有什么方法可以直接加载证书&以编程方式传输 SSLServerSocket (Java) 的私钥?
我来自“C”背景。我正在尝试分析如何编写Java SSL服务器。
到目前为止,我发现的示例都讨论了将证书和私有密钥加载到密钥库以及以编程方式将密钥库关联到 SSLContext,然后从中创建 SSLServerSocket。
但是,是否有任何方法可以直接提及 SSLServerSocket 应使用哪个证书?另外,即使我使用密钥库,并且如果有多个证书和密钥,我如何指定 SSLServerSocket 应该使用哪一个?
任何示例链接都会有所帮助。
I am from a 'C' background. I am trying to analyze how to write a Java SSL Server.
So, far the examples I found talk about loading certificate and private to a Key Store and the programmatically associating the KeyStore to SSLContext and then create a SSLServerSocket from the same.
But, are there any methods for directly mentioning which certificate the SSLServerSocket should use? Also, even if I use keystore and if there are multiple certificates and keys how can I specify to SSLServerSocket which one it should use?
Any sample link will be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如我在评论中所说,在 回答之前的一个问题,您需要使用
KeyManager
来执行此操作。有多种方法可以做到这一点。 jSSLutils 是一个可以使其更方便的库(但您也可以更手动地完成)。有一个使用 FixedServerAliasKeyManager 的示例。最短的方法之一是使用这样的东西:
As I was saying in a comment, in an answer to one of your questions earlier, you'll need to use a
KeyManager
to do this.There are various ways of doing this. jSSLutils is a library that can make it a bit more convenient (but you could also do it more manually). There's an example with the FixedServerAliasKeyManager. One of the shortest ways to do it would be to use something like this: