You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/08/29 21:11:23 UTC

svn commit: r1378686 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java

Author: tabish
Date: Wed Aug 29 19:11:22 2012
New Revision: 1378686

URL: http://svn.apache.org/viewvc?rev=1378686&view=rev
Log:
additional change for: https://issues.apache.org/jira/browse/AMQ-3996

The sslEngine instance in the NIOSSLTransport needs to be updated when the handshake process completes.


Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java?rev=1378686&r1=1378685&r2=1378686&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java Wed Aug 29 19:11:22 2012
@@ -52,7 +52,6 @@ public class NIOSSLTransport extends NIO
     protected SSLEngine sslEngine;
     protected SSLSession sslSession;
 
-
     protected boolean handshakeInProgress = false;
     protected SSLEngineResult.Status status = null;
     protected SSLEngineResult.HandshakeStatus handshakeStatus = null;
@@ -79,7 +78,8 @@ public class NIOSSLTransport extends NIO
                 sslContext = SSLContext.getDefault();
             }
 
-            // initialize engine
+            // initialize engine, the initial sslSession we get will need to be
+            // updated once the ssl handshake process is completed.
             sslEngine = sslContext.createSSLEngine();
             sslEngine.setUseClientMode(false);
             if (enabledCipherSuites != null) {
@@ -101,11 +101,9 @@ public class NIOSSLTransport extends NIO
             sslEngine.beginHandshake();
             handshakeStatus = sslEngine.getHandshakeStatus();
             doHandshake();
-
         } catch (Exception e) {
             throw new IOException(e);
         }
-
     }
 
     protected void finishHandshake() throws Exception  {
@@ -113,6 +111,11 @@ public class NIOSSLTransport extends NIO
               handshakeInProgress = false;
               nextFrameSize = -1;
 
+              // Once handshake completes we need to ask for the now real sslSession
+              // otherwise the session would return 'SSL_NULL_WITH_NULL_NULL' for the
+              // cipher suite.
+              sslSession = sslEngine.getSession();
+
               // listen for events telling us when the socket is readable.
               selection = SelectorManager.getInstance().register(channel, new SelectorManager.Listener() {
                   public void onSelect(SelectorSelection selection) {
@@ -164,7 +167,6 @@ public class NIOSSLTransport extends NIO
                 if (status == SSLEngineResult.Status.OK && handshakeStatus != SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
                     processCommand(plain);
                 }
-
             }
         } catch (IOException e) {
             onException(e);
@@ -281,8 +283,7 @@ public class NIOSSLTransport extends NIO
     }
 
     /**
-     * Overriding in order to add the client's certificates to ConnectionInfo
-     * Commmands.
+     * Overriding in order to add the client's certificates to ConnectionInfo Commmands.
      *
      * @param command The Command coming in.
      */