Netty中的两种SSL身份验证 [英] Two way SSL authentication in Netty
问题描述
我正在开发基于服务器和客户端的应用程序,这些应用程序需要两种SSL身份验证. (客户端使用SSL证书对服务器进行身份验证,而服务器均使用SSL证书对服务器进行身份验证.)
I'm working on a Server and Client based app which require two way SSL authentication. (Client authenticates server and Server authenticate client both using SSL Certificates.)
我是Netty的新手,对此几乎没有疑问.
I'm quite new to Netty and have few doubts regarding this.
- 使用Netty是否可以进行双向身份验证?
- 是否可以通过在服务器和客户端的管道工厂中添加另一个SslHandler来简单地实现?
- 如果以上情况正确,我如何在ChannelConnected()方法中获取所需的SslHandler来执行SslHandshake?并可以通过再次调用管道来在ChannelConected()方法上调用第二次握手吗?
- 关于这个我有什么例子可以参考吗?
我非常感谢您对此提供的任何帮助,答案或朝正确方向的推动.
I really appreciate any help regarding this, answers or a push in right direction.
非常感谢.
推荐答案
使用Netty是否可以进行双向身份验证?
是
是否可以通过在服务器和客户端的管道工厂中添加另一个SslHandler来简单地实现?
是
如果以上情况正确,我如何在ChannelConnected()方法中获取所需的SslHandler来进行SslHandshake?
在创建SSLContext
时,您需要正确设置密钥库和信任库.
You need the setup the keystore and the truststore correctly when creating your SSLContext
.
是否可以通过再次调用管道来在ChannelConected()方法上调用第二次握手?
从内存中,客户端和服务器的身份验证是在第一次握手中完成的.
From memory, client and server authentication is done in the 1st handshake.
在客户端上,将客户端的私钥安装在密钥库中,并将服务器的公钥安装在信任库中.
On the client, install the client's private key in the keystore and the server's public key in the truststore.
在服务器上,将服务器的私钥安装在密钥库中,并将客户端的公钥安装在信任库中.
On the server, install the server's private key in the keystore and the client's public key in the truststore.
有什么我可以参考的例子吗?
Here's an example I did for websockets. It only shows you how to setup the server keystore. You will have to add a truststore as the 2nd parameter of
serverContext.init(kmf.getKeyManagers(), null, null);
这是一个类似的这是一个很好的 java指南,如何设置SSLContext.
Here's a good java guide on how to setup SSLContext.
希望这会有所帮助.
这篇关于Netty中的两种SSL身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!