[Modify] Polish them
This commit is contained in:
parent
ed90f07b3e
commit
6faca0b6b4
@ -752,22 +752,14 @@ namespace WebSocketSharp.Server
|
|||||||
|| name == _hostname;
|
|| name == _hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool checkSslConfiguration (
|
private static bool checkSslConfiguration (
|
||||||
ServerSslConfiguration configuration, out string message
|
ServerSslConfiguration configuration, out string message
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
message = null;
|
message = null;
|
||||||
|
|
||||||
if (!_secure)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (configuration == null) {
|
|
||||||
message = "There is no configuration for secure connections.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.ServerCertificate == null) {
|
if (configuration.ServerCertificate == null) {
|
||||||
message = "There is no certificate in the configuration.";
|
message = "There is no server certificate for secure connections.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -782,9 +774,10 @@ namespace WebSocketSharp.Server
|
|||||||
|
|
||||||
private ServerSslConfiguration getSslConfiguration ()
|
private ServerSslConfiguration getSslConfiguration ()
|
||||||
{
|
{
|
||||||
return _secure && _sslConfig != null
|
if (_sslConfig == null)
|
||||||
? new ServerSslConfiguration (_sslConfig)
|
_sslConfig = new ServerSslConfiguration ();
|
||||||
: null;
|
|
||||||
|
return _sslConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init (
|
private void init (
|
||||||
@ -1322,11 +1315,15 @@ namespace WebSocketSharp.Server
|
|||||||
/// </exception>
|
/// </exception>
|
||||||
public void Start ()
|
public void Start ()
|
||||||
{
|
{
|
||||||
var sslConfig = getSslConfiguration ();
|
ServerSslConfiguration sslConfig = null;
|
||||||
|
|
||||||
string msg;
|
if (_secure) {
|
||||||
if (!checkSslConfiguration (sslConfig, out msg))
|
sslConfig = new ServerSslConfiguration (getSslConfiguration ());
|
||||||
throw new InvalidOperationException (msg);
|
|
||||||
|
string msg;
|
||||||
|
if (!checkSslConfiguration (sslConfig, out msg))
|
||||||
|
throw new InvalidOperationException (msg);
|
||||||
|
}
|
||||||
|
|
||||||
start (sslConfig);
|
start (sslConfig);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user