Mr.Wang from Next Door
Mr.Wang from Next Door

Reputation: 14820

Netty 4 : Configure client certificates in SslContextBuilder

I have a p12 format client ssl certificates.

How can I configure it in Netty in SslContextBuilder class?

Upvotes: 0

Views: 2678

Answers (1)

Leo Gomes
Leo Gomes

Reputation: 1153

Convert the .p12 to a Java Keystore.

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

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));

Upvotes: 2

Related Questions