This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-nms-openwire.git


The following commit(s) were added to refs/heads/master by this push:
     new c60e83a  Fix for NMS failover/TLS bug, AMQNET-572, by saving an Ssl 
context (moved to new directory location)
     new ed08387  Merge pull request #16 from brudo/fix-failover-dtaflin-reloc
c60e83a is described below

commit c60e83a170f589c8a67835b2d63a0b979fa8578a
Author: dtaflin <[email protected]>
AuthorDate: Tue Oct 17 18:48:42 2017 +0000

    Fix for NMS failover/TLS bug, AMQNET-572, by saving an Ssl context
    (moved to new directory location)
---
 src/Transport/Failover/FailoverTransport.cs | 11 ++++++++
 src/Transport/Tcp/SslContext.cs             | 41 +++++++++++++++++++++++++++++
 src/Transport/Tcp/SslTransportFactory.cs    | 10 +++++++
 3 files changed, 62 insertions(+)

diff --git a/src/Transport/Failover/FailoverTransport.cs 
b/src/Transport/Failover/FailoverTransport.cs
index 7fca5ae..c3faee0 100644
--- a/src/Transport/Failover/FailoverTransport.cs
+++ b/src/Transport/Failover/FailoverTransport.cs
@@ -90,6 +90,7 @@ namespace Apache.NMS.ActiveMQ.Transport.Failover
                private bool priorityBackup = false;
        private List<Uri> priorityList = new List<Uri>();
        private bool priorityBackupAvailable = false;
+        private String sslProtocol = null;
 
                // Not Sure how to work these back in with all the changes.
                //private int asyncTimeout = 45000;
@@ -1032,6 +1033,11 @@ namespace Apache.NMS.ActiveMQ.Transport.Failover
 
         private bool DoConnect()
         {
+            if (this.sslProtocol != null)
+            {
+                Tcp.SslContext.GetCurrent().SslProtocol = this.sslProtocol;
+            }
+
             lock(reconnectMutex)
             {
                                if (disposed || connectionFailure != null)
@@ -1205,6 +1211,11 @@ namespace Apache.NMS.ActiveMQ.Transport.Failover
                                    }
 
                                    connected = true;
+                                if (this.sslProtocol == null)
+                                {
+                                    this.sslProtocol = 
Tcp.SslContext.GetCurrent().SslProtocol;
+                                }
+
                                    return false;
                                }
                                                        catch (Exception e) 
diff --git a/src/Transport/Tcp/SslContext.cs b/src/Transport/Tcp/SslContext.cs
new file mode 100644
index 0000000..d35e0e2
--- /dev/null
+++ b/src/Transport/Tcp/SslContext.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+namespace Apache.NMS.ActiveMQ.Transport.Tcp
+{
+    class SslContext
+    {
+        private String sslProtocol;
+
+        public SslContext() : this("Tls")
+        {
+        }
+
+        public SslContext(String protocol)
+        {
+            this.sslProtocol = protocol;
+        }
+
+        public String SslProtocol
+        {
+            get { return this.sslProtocol; }
+            set { this.sslProtocol = value; }
+        }
+
+        [ThreadStatic]
+        static private SslContext current;
+
+        static public SslContext GetCurrent()
+        {
+            if (current == null)
+            {
+                current = new SslContext();
+            }
+            return current;
+        }
+
+        static public void SetCurrent(SslContext context)
+        {
+            current = context;
+        }
+    }
+}
diff --git a/src/Transport/Tcp/SslTransportFactory.cs 
b/src/Transport/Tcp/SslTransportFactory.cs
index 080aac3..2fdb7a1 100644
--- a/src/Transport/Tcp/SslTransportFactory.cs
+++ b/src/Transport/Tcp/SslTransportFactory.cs
@@ -97,6 +97,16 @@ namespace Apache.NMS.ActiveMQ.Transport.Tcp
             Tracer.Debug("Creating new instance of the SSL Transport.");
                        SslTransport transport = new SslTransport(location, 
socket, wireFormat);
 
+            if (this.sslProtocol == null)
+            {
+                this.sslProtocol = SslContext.GetCurrent().SslProtocol;
+            }
+            else
+            {
+                SslContext.GetCurrent().SslProtocol = this.sslProtocol;
+            }
+            Tracer.DebugFormat("SslProtocol: {0}", this.sslProtocol);
+
             transport.ClientCertSubject = 
HttpUtility.UrlDecode(this.clientCertSubject);
             transport.ClientCertFilename = this.clientCertFilename;
             transport.ClientCertPassword = this.clientCertPassword;

Reply via email to