Skip to content

Commit

Permalink
Merge pull request connamara#276 from akamyshanov/hotfix-ssl
Browse files Browse the repository at this point in the history
SSL Fixes
  • Loading branch information
cbusbey committed Feb 26, 2016
2 parents f6869e6 + 5f4bad6 commit 3dbf55b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion QuickFIXn/SocketSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace QuickFix
/// Property setters are internal so they can be set in tests, otherwise the settings should
/// be set using the <see cref="Configure"/> function
/// </remarks>
public class SocketSettings
public class SocketSettings : ICloneable
{
public bool SocketNodelay = true;
public Nullable<int> SocketReceiveBufferSize;
Expand Down Expand Up @@ -173,6 +173,14 @@ public void Configure(QuickFix.Dictionary dictionary)
}
}

object ICloneable.Clone()
{
return Clone();
}

public SocketSettings Clone()
{
return (SocketSettings)MemberwiseClone();
}
}
}
10 changes: 8 additions & 2 deletions QuickFIXn/Transport/SocketInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public SocketInitiator(IApplication application, IMessageStoreFactory storeFacto
public static void SocketInitiatorThreadStart(object socketInitiatorThread)
{
SocketInitiatorThread t = socketInitiatorThread as SocketInitiatorThread;
if (t == null) return;
try
{
t.Connect();
Expand All @@ -74,6 +75,10 @@ public static void SocketInitiatorThreadStart(object socketInitiatorThread)
{
t.Session.Log.OnEvent("Connection failed: " + e.Message);
}
catch (System.Security.Authentication.AuthenticationException ex) // some certificate problems
{
t.Session.Log.OnEvent("Connection failed (AuthenticationException): " + ex.Message);
}
catch (Exception)
{
// It might be the logger ObjectDisposedException, so don't try to log!
Expand Down Expand Up @@ -221,10 +226,11 @@ protected override void DoConnect(SessionID sessionID, Dictionary settings)
session.Log.OnEvent("Connecting to " + socketEndPoint.Address + " on port " + socketEndPoint.Port);

//Setup socket settings based on current section
socketSettings_.Configure(settings);
var socketSettings = socketSettings_.Clone();
socketSettings.Configure(settings);

// Create a Ssl-SocketInitiatorThread if a certificate is given
SocketInitiatorThread t = new SocketInitiatorThread(this, session, socketEndPoint, socketSettings_);
SocketInitiatorThread t = new SocketInitiatorThread(this, session, socketEndPoint, socketSettings);
t.Start();
AddThread(t);

Expand Down

0 comments on commit 3dbf55b

Please sign in to comment.