Fix for pull request #85, renamed DefaultSslConfiguration property to SslConfiguration property
This commit is contained in:
parent
912b1f0d62
commit
689cc28532
@ -28,8 +28,8 @@ namespace Example3
|
|||||||
#endif
|
#endif
|
||||||
/* To provide the secure connection.
|
/* To provide the secure connection.
|
||||||
var cert = ConfigurationManager.AppSettings["ServerCertFile"];
|
var cert = ConfigurationManager.AppSettings["ServerCertFile"];
|
||||||
var password = ConfigurationManager.AppSettings["CertFilePassword"];
|
var passwd = ConfigurationManager.AppSettings["CertFilePassword"];
|
||||||
httpsv.Certificate = new X509Certificate2 (cert, password);
|
httpsv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* To provide the HTTP Authentication (Basic/Digest).
|
/* To provide the HTTP Authentication (Basic/Digest).
|
||||||
|
@ -114,7 +114,7 @@ namespace WebSocketSharp.Net
|
|||||||
port,
|
port,
|
||||||
secure,
|
secure,
|
||||||
httpListener.CertificateFolderPath,
|
httpListener.CertificateFolderPath,
|
||||||
httpListener.DefaultSslConfiguration,
|
httpListener.SslConfiguration,
|
||||||
httpListener.ReuseAddress);
|
httpListener.ReuseAddress);
|
||||||
|
|
||||||
eps[port] = epl;
|
eps[port] = epl;
|
||||||
|
@ -71,13 +71,13 @@ namespace WebSocketSharp.Net
|
|||||||
private Dictionary<HttpListenerContext, HttpListenerContext> _ctxRegistry;
|
private Dictionary<HttpListenerContext, HttpListenerContext> _ctxRegistry;
|
||||||
private object _ctxRegistrySync;
|
private object _ctxRegistrySync;
|
||||||
private Func<IIdentity, NetworkCredential> _credFinder;
|
private Func<IIdentity, NetworkCredential> _credFinder;
|
||||||
private ServerSslAuthConfiguration _defaultSslConfig;
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
private bool _ignoreWriteExceptions;
|
private bool _ignoreWriteExceptions;
|
||||||
private bool _listening;
|
private bool _listening;
|
||||||
private HttpListenerPrefixCollection _prefixes;
|
private HttpListenerPrefixCollection _prefixes;
|
||||||
private string _realm;
|
private string _realm;
|
||||||
private bool _reuseAddress;
|
private bool _reuseAddress;
|
||||||
|
private ServerSslAuthConfiguration _sslConfig;
|
||||||
private List<ListenerAsyncResult> _waitQueue;
|
private List<ListenerAsyncResult> _waitQueue;
|
||||||
private object _waitQueueSync;
|
private object _waitQueueSync;
|
||||||
|
|
||||||
@ -219,29 +219,6 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the default SSL configuration used to authenticate the server and
|
|
||||||
/// optionally the client on the secure connection.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>
|
|
||||||
/// A <see cref="ServerSslAuthConfiguration"/> that represents the SSL configuration used to
|
|
||||||
/// authenticate the server optionally the client. The default value is <see langword="null"/>.
|
|
||||||
/// </value>
|
|
||||||
/// <exception cref="ObjectDisposedException">
|
|
||||||
/// This listener has been closed.
|
|
||||||
/// </exception>
|
|
||||||
public ServerSslAuthConfiguration DefaultSslConfiguration {
|
|
||||||
get {
|
|
||||||
CheckDisposed ();
|
|
||||||
return _defaultSslConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
CheckDisposed ();
|
|
||||||
_defaultSslConfig = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the listener returns exceptions that occur when
|
/// Gets or sets a value indicating whether the listener returns exceptions that occur when
|
||||||
/// sending the response to the client.
|
/// sending the response to the client.
|
||||||
@ -329,6 +306,29 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the SSL configuration used to authenticate the server and optionally the client
|
||||||
|
/// for secure connection.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// A <see cref="ServerSslAuthConfiguration"/> that represents the configuration used to
|
||||||
|
/// authenticate the server and optionally the client for secure connection.
|
||||||
|
/// </value>
|
||||||
|
/// <exception cref="ObjectDisposedException">
|
||||||
|
/// This listener has been closed.
|
||||||
|
/// </exception>
|
||||||
|
public ServerSslAuthConfiguration SslConfiguration {
|
||||||
|
get {
|
||||||
|
CheckDisposed ();
|
||||||
|
return _sslConfig ?? (_sslConfig = new ServerSslAuthConfiguration (null));
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
CheckDisposed ();
|
||||||
|
_sslConfig = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether, when NTLM authentication is used,
|
/// Gets or sets a value indicating whether, when NTLM authentication is used,
|
||||||
/// the authentication information of first request is used to authenticate
|
/// the authentication information of first request is used to authenticate
|
||||||
|
@ -336,15 +336,15 @@ namespace WebSocketSharp.Server
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the SSL configuration used to authenticate the server and optionally the client
|
/// Gets or sets the SSL configuration used to authenticate the server and optionally the client
|
||||||
/// on the secure connection.
|
/// for secure connection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// A <see cref="ServerSslAuthConfiguration"/> that represents the SSL configuration used to
|
/// A <see cref="ServerSslAuthConfiguration"/> that represents the configuration used to
|
||||||
/// authenticate the server and optionally the client.
|
/// authenticate the server and optionally the client for secure connection.
|
||||||
/// </value>
|
/// </value>
|
||||||
public ServerSslAuthConfiguration SslConfiguration {
|
public ServerSslAuthConfiguration SslConfiguration {
|
||||||
get {
|
get {
|
||||||
return _listener.DefaultSslConfiguration;
|
return _listener.SslConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
@ -354,10 +354,7 @@ namespace WebSocketSharp.Server
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EndPointListener.CertificateExists (_port, _listener.CertificateFolderPath))
|
_listener.SslConfiguration = value;
|
||||||
_logger.Warn ("The server certificate associated with the port number already exists.");
|
|
||||||
|
|
||||||
_listener.DefaultSslConfiguration = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,10 +505,17 @@ namespace WebSocketSharp.Server
|
|||||||
|
|
||||||
private string checkIfCertificateExists ()
|
private string checkIfCertificateExists ()
|
||||||
{
|
{
|
||||||
return _secure &&
|
if (!_secure)
|
||||||
!EndPointListener.CertificateExists (_port, _listener.CertificateFolderPath) &&
|
return null;
|
||||||
(_listener.DefaultSslConfiguration == null ||
|
|
||||||
_listener.DefaultSslConfiguration.ServerCertificate == null)
|
var usr = _listener.SslConfiguration.ServerCertificate != null;
|
||||||
|
var port = EndPointListener.CertificateExists (_port, _listener.CertificateFolderPath);
|
||||||
|
if (usr && port) {
|
||||||
|
_logger.Warn ("The server certificate associated with the port number already exists.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(usr || port)
|
||||||
? "The secure connection requires a server certificate."
|
? "The secure connection requires a server certificate."
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user