From 4c9f443beaa2b8da8002e3989629349c6af46e2e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Oct 2017 14:45:22 +0900 Subject: [PATCH] [Modify] Remove it and throw exception --- websocket-sharp/WebSocket.cs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index da104d61..8403132c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -651,23 +651,20 @@ namespace WebSocketSharp /// public ClientSslConfiguration SslConfiguration { get { - return _client - ? (_sslConfig ?? (_sslConfig = new ClientSslConfiguration (_uri.DnsSafeHost))) - : null; - } + if (!_client) { + var msg = "This instance is not a client."; + throw new InvalidOperationException (msg); + } - set { - lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the ssl configuration.", null); + if (!_secure) { + var msg = "The connection is not secure."; + throw new InvalidOperationException (msg); + } - return; - } + if (_sslConfig == null) + _sslConfig = new ClientSslConfiguration (_uri.DnsSafeHost); - _sslConfig = value; - } + return _sslConfig; } }