Netty 4:在SslContextBuilder中配置客户端证书 [英] Netty 4 : Configure client certificates in SslContextBuilder
本文介绍了Netty 4:在SslContextBuilder中配置客户端证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个p12格式的客户端ssl证书.
I have a p12 format client ssl certificates.
如何在Netty中的 SslContextBuilder 上课?
How can I configure it in Netty in SslContextBuilder class?
推荐答案
启动应用程序时,请确保设置以下系统属性以及Java密钥库(.jks)的路径并提供密码:
When starting your application, make sure you set the following system properties with the path to your Java Keystore (.jks) and given password:
- javax.net.ssl.keyStore
- javax.net.ssl.keyStorePassword
然后,您可以创建一个默认的SSLContext,如下所示,并将其添加到Netty的管道中:
Then, you can create a default SSLContext as shown below and add it to Netty's pipeline:
SSLContext ctx = SSLContext.getDefault();
SSLEngine engine = ctx.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("sslHandler", new SslHandler(engine));
这篇关于Netty 4:在SslContextBuilder中配置客户端证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文