namespace WatsonTcp
{
using System;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
///
/// Stores the parameters for the used by servers.
///
public class WatsonTcpServerSslConfiguration
{
#region Public-Members
///
/// Gets or sets a value indicating whether the client is asked for
/// a certificate for authentication.
///
public bool ClientCertificateRequired
{
get
{
return _ClientCertRequired;
}
set
{
_ClientCertRequired = value;
}
}
///
/// Gets or sets a delegate responsible
/// for validating the certificate supplied by the remote party.
///
///
/// The default delegate returns true for all certificates
///
public RemoteCertificateValidationCallback ClientCertificateValidationCallback
{
get
{
if (_ClientCertValidationCallback == null)
_ClientCertValidationCallback = DefaultValidateClientCertificate;
return _ClientCertValidationCallback;
}
set
{
_ClientCertValidationCallback = value;
}
}
#endregion
#region Private-Members
private bool _ClientCertRequired = true;
private RemoteCertificateValidationCallback _ClientCertValidationCallback;
#endregion
#region Constructors-and-Factories
///
/// Initializes a new instance of .
///
public WatsonTcpServerSslConfiguration()
{
}
///
/// Initializes a new instance of the
/// class that stores the parameters copied from another configuration.
///
///
/// A from which to copy.
///
///
public WatsonTcpServerSslConfiguration(WatsonTcpServerSslConfiguration configuration)
{
if (configuration == null)
throw new ArgumentNullException("Can not copy from null server SSL configuration");
_ClientCertRequired = configuration._ClientCertRequired;
_ClientCertValidationCallback = configuration._ClientCertValidationCallback;
}
#endregion
#region Public-Methods
#endregion
#region Private-Methods
private static bool DefaultValidateClientCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
{
return true;
}
#endregion
}
}