#region License /* * ClientSslConfiguration.cs * * The MIT License * * Copyright (c) 2014 liryna * Copyright (c) 2014 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #endregion #region Authors /* * Authors: * - Liryna */ #endregion using System.Net.Security; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; namespace WebSocketSharp.Net { /// /// Stores the parameters used to configure a instance as a client. /// public class ClientSslConfiguration : SslConfiguration { #region Private Fields private X509CertificateCollection _certs; private string _host; #endregion #region Public Constructors /// /// Initializes a new instance of the class with /// the specified . /// /// /// A that represents the name of the server that shares /// a secure connection. /// public ClientSslConfiguration (string targetHost) : this (targetHost, null, SslProtocols.Default, false) { } /// /// Initializes a new instance of the class with /// the specified , , /// , and . /// /// /// A that represents the name of the server that shares /// a secure connection. /// /// /// A that contains client certificates. /// /// /// The enum value that represents the protocols used for /// authentication. /// /// /// true if the certificate revocation list is checked during authentication; /// otherwise, false. /// public ClientSslConfiguration ( string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation) : base (enabledSslProtocols, checkCertificateRevocation) { _host = targetHost; _certs = clientCertificates; } #endregion #region Public Properties /// /// Gets or sets the collection that contains client certificates. /// /// /// A that contains client certificates. /// public X509CertificateCollection ClientCertificates { get { return _certs; } set { _certs = value; } } /// /// Gets or sets the callback used to select a client certificate to supply to the server. /// /// /// If this callback returns , no client certificate will be supplied. /// /// /// A delegate that references the method /// used to select the client certificate. The default value is a function that only returns /// . /// public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { get { return CertificateSelectionCallback; } set { CertificateSelectionCallback = value; } } /// /// Gets or sets the callback used to validate the certificate supplied by the server. /// /// /// If this callback returns true, the server certificate will be valid. /// /// /// A delegate that references the method /// used to validate the server certificate. The default value is a function that only returns /// true. /// public RemoteCertificateValidationCallback ServerCertificateValidationCallback { get { return CertificateValidationCallback; } set { CertificateValidationCallback = value; } } /// /// Gets or sets the name of the server that shares a secure connection. /// /// /// A that represents the name of the server that shares /// a secure connection. /// public string TargetHost { get { return _host; } set { _host = value; } } #endregion } }