Fix for pull request #85, added TargetHost property to ClientSslAuthConfiguration class, and refactored

This commit is contained in:
sta
2014-11-03 15:11:43 +09:00
parent 1fc568c4e8
commit c511f9d7ac
2 changed files with 54 additions and 46 deletions

View File

@@ -34,14 +34,14 @@
*/
#endregion
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
namespace WebSocketSharp.Net
{
/// <summary>
/// Stores the parameters used in configuring <see cref="System.Net.Security.SslStream"/>
/// as a client.
/// Stores the parameters used to configure a <see cref="SslStream"/> instance as a client.
/// </summary>
public class ClientSslAuthConfiguration
{
@@ -49,39 +49,26 @@ namespace WebSocketSharp.Net
/// <summary>
/// Initializes a new instance of the <see cref="ClientSslAuthConfiguration"/> class with
/// the specified <paramref name="clientCertificates"/>.
/// the specified <paramref name="targetHost"/>.
/// </summary>
/// <param name="clientCertificates">
/// A <see cref="X509CertificateCollection"/> that contains client certificates.
/// <param name="targetHost">
/// A <see cref="string"/> that represents the name of the server that shares
/// a secure connection.
/// </param>
public ClientSslAuthConfiguration (X509CertificateCollection clientCertificates)
: this (clientCertificates, SslProtocols.Default, false)
public ClientSslAuthConfiguration (string targetHost)
: this (targetHost, null, SslProtocols.Default, false)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ClientSslAuthConfiguration"/> class with
/// the specified <paramref name="clientCertificates"/> and
/// <paramref name="enabledSslProtocols"/>.
/// the specified <paramref name="targetHost"/>, <paramref name="clientCertificates"/>,
/// <paramref name="enabledSslProtocols"/>, and <paramref name="checkCertificateRevocation"/>.
/// </summary>
/// <param name="clientCertificates">
/// A <see cref="X509CertificateCollection"/> that contains client certificates.
/// <param name="targetHost">
/// A <see cref="string"/> that represents the name of the server that shares
/// a secure connection.
/// </param>
/// <param name="enabledSslProtocols">
/// The <see cref="SslProtocols"/> enum value that represents the protocols used for
/// authentication.
/// </param>
public ClientSslAuthConfiguration (
X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols)
: this (clientCertificates, enabledSslProtocols, false)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ClientSslAuthConfiguration"/> class with
/// the specified <paramref name="clientCertificates"/>, <paramref name="enabledSslProtocols"/>,
/// and <paramref name="checkCertificateRevocation"/>.
/// </summary>
/// <param name="clientCertificates">
/// A <see cref="X509CertificateCollection"/> that contains client certificates.
/// </param>
@@ -94,10 +81,12 @@ namespace WebSocketSharp.Net
/// otherwise, <c>false</c>.
/// </param>
public ClientSslAuthConfiguration (
string targetHost,
X509CertificateCollection clientCertificates,
SslProtocols enabledSslProtocols,
bool checkCertificateRevocation)
{
TargetHost = targetHost;
ClientCertificates = clientCertificates;
EnabledSslProtocols = enabledSslProtocols;
CheckCertificateRevocation = checkCertificateRevocation;
@@ -133,6 +122,15 @@ namespace WebSocketSharp.Net
/// </value>
public SslProtocols EnabledSslProtocols { get; set; }
/// <summary>
/// Gets or sets the name of the server that shares a secure connection.
/// </summary>
/// <value>
/// A <see cref="string"/> that represents the name of the server that shares
/// a secure connection.
/// </value>
public string TargetHost { get; set; }
#endregion
}
}