pvillard31 commented on code in PR #11959:
URL: https://github.com/apache/nifi/pull/11959#discussion_r4646378695


##########
nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/io/socket/SocketUtils.java:
##########
@@ -116,7 +99,25 @@ public static Socket createSocket(final InetSocketAddress 
address, final SocketC
             throw e;
         }
 
-        return socket;
+        final Socket connectedSocket;
+
+        final SSLContext sslContext = config.getSslContext();
+        if (sslContext == null) {
+            connectedSocket = socket;
+        } else {
+            // Create SSLSocket after successful connection to support 
hostname verification
+            final SSLSocketFactory sslSocketFactory = 
sslContext.getSocketFactory();
+            final SSLSocket sslSocket = (SSLSocket) 
sslSocketFactory.createSocket(socket, address.getHostName(), address.getPort(), 
true);

Review Comment:
   Should we close the connected socket if creating or configuring the 
SSLSocket throws, like the connect block does with closeQuietly?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to