From 9648606bdc84ec7dbf84235ac5a5365b2e943b1b Mon Sep 17 00:00:00 2001 From: JKorf Date: Tue, 27 Nov 2018 13:40:28 +0100 Subject: [PATCH] Fixed nullpointer on socket --- CryptoExchange.Net/Interfaces/IWebsocket.cs | 3 +-- CryptoExchange.Net/SocketClient.cs | 3 --- CryptoExchange.Net/Sockets/BaseSocket.cs | 2 ++ 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CryptoExchange.Net/Interfaces/IWebsocket.cs b/CryptoExchange.Net/Interfaces/IWebsocket.cs index 8f4eef9..44119e3 100644 --- a/CryptoExchange.Net/Interfaces/IWebsocket.cs +++ b/CryptoExchange.Net/Interfaces/IWebsocket.cs @@ -22,8 +22,7 @@ namespace CryptoExchange.Net.Interfaces bool IsOpen { get; } bool PingConnection { get; set; } TimeSpan PingInterval { get; set; } - - void SetEnabledSslProtocols(SslProtocols protocols); + SslProtocols SSLProtocols { get; set; } Task Connect(); void Send(string data); Task Close(); diff --git a/CryptoExchange.Net/SocketClient.cs b/CryptoExchange.Net/SocketClient.cs index 0184bb6..ab57ffd 100644 --- a/CryptoExchange.Net/SocketClient.cs +++ b/CryptoExchange.Net/SocketClient.cs @@ -22,8 +22,6 @@ namespace CryptoExchange.Net /// public virtual IWebsocketFactory SocketFactory { get; set; } = new WebsocketFactory(); - private const SslProtocols protocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; - protected List sockets = new List(); protected TimeSpan reconnectInterval; @@ -66,7 +64,6 @@ namespace CryptoExchange.Net if (apiProxy != null) socket.SetProxy(apiProxy.Host, apiProxy.Port); - socket.SetEnabledSslProtocols(protocols); socket.DataInterpreter = dataInterpreter; socket.OnClose += () => { diff --git a/CryptoExchange.Net/Sockets/BaseSocket.cs b/CryptoExchange.Net/Sockets/BaseSocket.cs index 79084aa..3b6a43a 100644 --- a/CryptoExchange.Net/Sockets/BaseSocket.cs +++ b/CryptoExchange.Net/Sockets/BaseSocket.cs @@ -37,6 +37,7 @@ namespace CryptoExchange.Net.Sockets public string Url { get; } public bool IsClosed => socket.State == WebSocketState.Closed; public bool IsOpen => socket.State == WebSocketState.Open; + public SslProtocols SSLProtocols { get; set; } = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; public Func DataInterpreter { get; set; } public bool PingConnection @@ -161,6 +162,7 @@ namespace CryptoExchange.Net.Sockets EnableAutoSendPing = true, AutoSendPingInterval = 10 }; + socket.Security.EnabledSslProtocols = SSLProtocols; socket.Opened += (o, s) => Handle(openHandlers); socket.Closed += (o, s) => Handle(closeHandlers); socket.Error += (o, s) => Handle(errorHandlers, s.Exception);