#region License /* * SslConfiguration.cs * * This code is derived from 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; namespace WebSocketSharp.Net { /// /// Stores the parameters used to configure a instance. /// /// /// The SslConfiguration class is an abstract class. /// public abstract class SslConfiguration { #region Private Fields private LocalCertificateSelectionCallback _certSelectionCallback; private RemoteCertificateValidationCallback _certValidationCallback; private bool _checkCertRevocation; private SslProtocols _enabledProtocols; #endregion #region Protected Constructors /// /// Initializes a new instance of the class with /// the specified and /// . /// /// /// The enum value that represents the protocols used for /// authentication. /// /// /// true if the certificate revocation list is checked during authentication; /// otherwise, false. /// protected SslConfiguration (SslProtocols enabledSslProtocols, bool checkCertificateRevocation) { _enabledProtocols = enabledSslProtocols; _checkCertRevocation = checkCertificateRevocation; } #endregion #region Protected Properties /// /// Gets or sets the callback used to select a certificate to supply to the remote party. /// /// /// If this callback returns , no certificate will be supplied. /// /// /// A delegate that references the method /// used to select a certificate. The default value is a function that only returns /// . /// protected LocalCertificateSelectionCallback CertificateSelectionCallback { get { return _certSelectionCallback ?? (_certSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => null); } set { _certSelectionCallback = value; } } /// /// Gets or sets the callback used to validate the certificate supplied by the remote party. /// /// /// If this callback returns true, the certificate will be valid. /// /// /// A delegate that references the method /// used to validate the certificate. The default value is a function that only returns /// true. /// protected RemoteCertificateValidationCallback CertificateValidationCallback { get { return _certValidationCallback ?? (_certValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true); } set { _certValidationCallback = value; } } #endregion #region Public Properties /// /// Gets or sets a value indicating whether the certificate revocation list is checked /// during authentication. /// /// /// true if the certificate revocation list is checked; otherwise, false. /// public bool CheckCertificateRevocation { get { return _checkCertRevocation; } set { _checkCertRevocation = value; } } /// /// Gets or sets the SSL protocols used for authentication. /// /// /// The enum value that represents the protocols used for /// authentication. /// public SslProtocols EnabledSslProtocols { get { return _enabledProtocols; } set { _enabledProtocols = value; } } #endregion } }