You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/03/08 09:11:30 UTC

[GitHub] [ratis] lokeshj1703 commented on a change in pull request #615: RATIS-1541. Add SslContext to netty ChannelPipeline.

lokeshj1703 commented on a change in pull request #615:
URL: https://github.com/apache/ratis/pull/615#discussion_r821461256



##########
File path: ratis-netty/src/main/java/org/apache/ratis/netty/NettyUtils.java
##########
@@ -40,4 +49,78 @@ static EventLoopGroup newEventLoopGroup(String name, int size, boolean useEpoll)
     }
     return new NioEventLoopGroup(size, ConcurrentUtils.newThreadFactory(name + "-"));
   }
+
+  static void setTrustManager(SslContextBuilder b, TrustManagerConf trustManagerConfig) {
+    if (trustManagerConfig == null) {
+      return;
+    }
+    final CertificatesConf certificates = trustManagerConfig.getTrustCertificates();
+    if (certificates.isFileBased()) {
+      b.trustManager(certificates.getFile());
+    } else {
+      b.trustManager(certificates.get());
+    }
+  }
+
+  static void setKeyManager(SslContextBuilder b, KeyManagerConf keyManagerConfig) {
+    if (keyManagerConfig == null) {
+      return;
+    }
+    final PrivateKeyConf privateKey = keyManagerConfig.getPrivateKey();
+    final CertificatesConf certificates = keyManagerConfig.getKeyCertificates();
+
+    if (keyManagerConfig.isFileBased()) {
+      b.keyManager(certificates.getFile(), privateKey.getFile());
+    } else {
+      b.keyManager(privateKey.get(), certificates.get());

Review comment:
       Unrelated to PR. It would be better to have same order of private key and certificates in the constructors for SslContextBuilder.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org