From 6faca0b6b4c57c24aacd8ea3af3b723e7a43aad3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Oct 2017 15:30:41 +0900 Subject: [PATCH] [Modify] Polish them --- websocket-sharp/Server/WebSocketServer.cs | 31 ++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2aae18e1..0dd0a091 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -752,22 +752,14 @@ namespace WebSocketSharp.Server || name == _hostname; } - private bool checkSslConfiguration ( + private static bool checkSslConfiguration ( ServerSslConfiguration configuration, out string message ) { message = null; - if (!_secure) - return true; - - if (configuration == null) { - message = "There is no configuration for secure connections."; - return false; - } - if (configuration.ServerCertificate == null) { - message = "There is no certificate in the configuration."; + message = "There is no server certificate for secure connections."; return false; } @@ -782,9 +774,10 @@ namespace WebSocketSharp.Server private ServerSslConfiguration getSslConfiguration () { - return _secure && _sslConfig != null - ? new ServerSslConfiguration (_sslConfig) - : null; + if (_sslConfig == null) + _sslConfig = new ServerSslConfiguration (); + + return _sslConfig; } private void init ( @@ -1322,11 +1315,15 @@ namespace WebSocketSharp.Server /// public void Start () { - var sslConfig = getSslConfiguration (); + ServerSslConfiguration sslConfig = null; - string msg; - if (!checkSslConfiguration (sslConfig, out msg)) - throw new InvalidOperationException (msg); + if (_secure) { + sslConfig = new ServerSslConfiguration (getSslConfiguration ()); + + string msg; + if (!checkSslConfiguration (sslConfig, out msg)) + throw new InvalidOperationException (msg); + } start (sslConfig); }