[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/uServe-UP/NetCoreServer/master/source/NetCoreServer/SslContext.cs [Back]  [Original]

using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;

namespace NetCoreServer
{
    /// 
    /// SSL context
    /// 
    public class SslContext
    {
        /// 
        /// Initialize SSL context with default protocols
        /// 
        public SslContext() : this(SslProtocols.Tls12) {}
        /// 
        /// Initialize SSL context with given protocols
        /// 
        /// SSL protocols
        public SslContext(SslProtocols protocols) { Protocols = protocols; }
        /// 
        /// Initialize SSL context with given protocols and certificate
        /// 
        /// SSL protocols
        /// SSL certificate
        public SslContext(SslProtocols protocols, X509Certificate certificate) : this(protocols, certificate, null) {}
        /// 
        /// Initialize SSL context with given protocols, certificate and validation callback
        /// 
        /// SSL protocols
        /// SSL certificate
        /// SSL certificate
        public SslContext(SslProtocols protocols, X509Certificate certificate, RemoteCertificateValidationCallback certificateValidationCallback)
        {
            Protocols = protocols;
            Certificate = certificate;
            CertificateValidationCallback = certificateValidationCallback;
        }
        /// 
        /// Initialize SSL context with given protocols and certificates collection
        /// 
        /// SSL protocols
        /// SSL certificates collection
        public SslContext(SslProtocols protocols, X509Certificate2Collection certificates) : this(protocols, certificates, null) {}
        /// 
        /// Initialize SSL context with given protocols, certificates collection and validation callback
        /// 
        /// SSL protocols
        /// SSL certificates collection
        /// SSL certificate
        public SslContext(SslProtocols protocols, X509Certificate2Collection certificates, RemoteCertificateValidationCallback certificateValidationCallback)
        {
            Protocols = protocols;
            Certificates = certificates;
            CertificateValidationCallback = certificateValidationCallback;
        }

        /// 
        /// SSL protocols
        /// 
        public SslProtocols Protocols { get; set; }
        /// 
        /// SSL certificate
        /// 
        public X509Certificate Certificate { get; set; }
        /// 
        /// SSL certificates collection
        /// 
        public X509Certificate2Collection Certificates { get; set; }
        /// 
        /// SSL certificate validation callback
        /// 
        public RemoteCertificateValidationCallback CertificateValidationCallback { get; set; }

        /// 
        /// Is the client is asked for a certificate for authentication.
        /// Note that this is only a request - if no certificate is provided, the server still accepts the connection request.
        /// 
        public bool ClientCertificateRequired { get; set; }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page