• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SslProtocols类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SslProtocols的典型用法代码示例。如果您正苦于以下问题:C# SslProtocols类的具体用法?C# SslProtocols怎么用?C# SslProtocols使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SslProtocols类属于命名空间,在下文中一共展示了SslProtocols类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MakeString

		/// <summary>
		/// see https://www.openssl.org/docs/apps/ciphers.html
		/// for details about OpenSSL cipher string
		/// </summary>
		/// <returns>The string.</returns>
		/// <param name="sslProtocols">SSL protocols.</param>
		/// <param name="sslStrength">SSL strength.</param>
		public static string MakeString(SslProtocols sslProtocols, SslStrength sslStrength)
		{
			var parts = new List<string>();

			if (EnumExtensions.HasFlag(sslStrength, SslStrength.High))
			{
				parts.Add("HIGH");
			}

			if (EnumExtensions.HasFlag(sslStrength, SslStrength.Medium))
			{
				parts.Add("MEDIUM");
			}

			if (EnumExtensions.HasFlag(sslStrength, SslStrength.Low))
			{
				parts.Add("LOW");
			}

			if ((sslProtocols == SslProtocols.Default) ||
				(sslProtocols == SslProtocols.Tls) ||
				(sslProtocols == SslProtocols.Ssl3))
			{
				parts.Add("!SSLv2");
			}

			parts.Add("!ADH");
			parts.Add("!aNULL");
			parts.Add("!eNULL");
			parts.Add("@STRENGTH");

			return string.Join(":", parts.ToArray());
		}
开发者ID:yaobos,项目名称:openssl-net,代码行数:40,代码来源:SslCipher.cs


示例2: DisabledProtocols_SetSslProtocols_ThrowsException

#pragma warning restore 0618
        public void DisabledProtocols_SetSslProtocols_ThrowsException(SslProtocols disabledProtocols)
        {
            using (var handler = new HttpClientHandler())
            {
                Assert.Throws<NotSupportedException>(() => handler.SslProtocols = disabledProtocols);
            }
        }
开发者ID:alessandromontividiu03,项目名称:corefx,代码行数:8,代码来源:HttpClientHandlerTest.SslProtocols.cs


示例3: BeginAuthenticateAsClient

 public virtual IAsyncResult BeginAuthenticateAsClient(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
 {
     this._SslState.ValidateCreateContext(false, targetHost, enabledSslProtocols, null, clientCertificates, true, checkCertificateRevocation);
     LazyAsyncResult lazyResult = new LazyAsyncResult(this._SslState, asyncState, asyncCallback);
     this._SslState.ProcessAuthentication(lazyResult);
     return lazyResult;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:SslStream.cs


示例4: HttpListenerBase

 /// <summary>
 /// Initializes a new instance of the <see cref="HttpListenerBase"/> class.
 /// </summary>
 /// <param name="address">IP Address to accept connections on</param>
 /// <param name="port">TCP Port to listen on, default HTTPS port is 443</param>
 /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param>
 /// <param name="certificate">Certificate to use</param>
 /// <param name="protocol">which HTTPS protocol to use, default is TLS.</param>
 protected HttpListenerBase(
     IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate,
     SslProtocols protocol)
     : this(address, port, factory, certificate)
 {
   _sslProtocol = protocol;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:15,代码来源:HttpListenerBase.cs


示例5: SslServer

        public SslServer(X509Certificate2 cert, bool certRequired, SslProtocols enabledProt, bool expectedExcep)
        {
            certificate = cert;
            clientCertificateRequired = certRequired;
            enabledSslProtocols = enabledProt;
            expectedException = expectedExcep;

            if (!certificate.HasPrivateKey)
            {
                Console.WriteLine("ERROR: The cerfiticate does not have a private key.");
                throw new Exception("No Private Key in the certificate file");
            }

            //Get the IPV4 address on this machine which is all that the MF devices support.
            foreach (IPAddress address in Dns.GetHostAddresses(Dns.GetHostName()))
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    ipAddress = address;
                    break;
                }
            }

            if (ipAddress == null)
                throw new Exception("No IPV4 address found.");

            //Console.WriteLine("ipAddress is: " + ipAddress.ToString());
            //Console.WriteLine("port          is: " + port.ToString());
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:29,代码来源:SslServer.cs


示例6: SecureChannel

        internal SecureChannel(string hostname, bool serverMode, SslProtocols sslProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool remoteCertRequired, bool checkCertName,
                                                  bool checkCertRevocationStatus, EncryptionPolicy encryptionPolicy, LocalCertSelectionCallback certSelectionDelegate)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(this, hostname, clientCertificates);
                NetEventSource.Log.SecureChannelCtor(this, hostname, clientCertificates, encryptionPolicy);
            }

            SslStreamPal.VerifyPackageInfo();

            _destination = hostname;

            if (hostname == null)
            {
                NetEventSource.Fail(this, "hostname == null");
            }
            _hostName = hostname;
            _serverMode = serverMode;

            _sslProtocols = sslProtocols;

            _serverCertificate = serverCertificate;
            _clientCertificates = clientCertificates;
            _remoteCertRequired = remoteCertRequired;
            _securityContext = null;
            _checkCertRevocation = checkCertRevocationStatus;
            _checkCertName = checkCertName;
            _certSelectionDelegate = certSelectionDelegate;
            _refreshCredentialNeeded = true;
            _encryptionPolicy = encryptionPolicy;
            
            if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:34,代码来源:SecureChannel.cs


示例7: SecureHttpContext

 /// <summary>
 /// Initializes a new instance of the <see cref="SecureHttpContext"/> class.
 /// </summary>
 /// <param name="protocols">SSL protocol to use.</param>
 /// <param name="socket">The socket.</param>
 /// <param name="context">The context.</param>
 /// <param name="certificate">Server certificate to use.</param>
 public SecureHttpContext(X509Certificate certificate, SslProtocols protocols, Socket socket,
                          MessageFactoryContext context)
     : base(socket, context)
 {
     _certificate = certificate;
     Protocol = protocols;
 }
开发者ID:rafavg77,项目名称:MissVenom,代码行数:14,代码来源:SecureHttpContext.cs


示例8: SecureChannel

        internal SecureChannel(string hostname, bool serverMode, SslProtocols sslProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool remoteCertRequired, bool checkCertName,
                                                  bool checkCertRevocationStatus, EncryptionPolicy encryptionPolicy, LocalCertSelectionCallback certSelectionDelegate)
        {
            GlobalLog.Enter("SecureChannel#" + Logging.HashString(this) + "::.ctor", "hostname:" + hostname + " #clientCertificates=" + ((clientCertificates == null) ? "0" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
            if (Logging.On)
            { 
                Logging.PrintInfo(Logging.Web, this, ".ctor", "hostname=" + hostname + ", #clientCertificates=" + ((clientCertificates == null) ? "0" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)) + ", encryptionPolicy=" + encryptionPolicy);
            }
          
            SSPIWrapper.VerifyPackageInfo(GlobalSSPI.SSPISecureChannel);

            _destination = hostname;

            GlobalLog.Assert(hostname != null, "SecureChannel#{0}::.ctor()|hostname == null", Logging.HashString(this));
            _hostName = hostname;
            _serverMode = serverMode;

            _sslProtocols = sslProtocols;

            _serverCertificate = serverCertificate;
            _clientCertificates = clientCertificates;
            _remoteCertRequired = remoteCertRequired;
            _securityContext = null;
            _checkCertRevocation = checkCertRevocationStatus;
            _checkCertName = checkCertName;
            _certSelectionDelegate = certSelectionDelegate;
            _refreshCredentialNeeded = true;
            _encryptionPolicy = encryptionPolicy;
            GlobalLog.Leave("SecureChannel#" + Logging.HashString(this) + "::.ctor");
        }
开发者ID:andyhebear,项目名称:corefx,代码行数:30,代码来源:_SecureChannel.cs


示例9: ClientAsyncAuthenticate_EachClientUnsupportedProtocol_Fail

 public async Task ClientAsyncAuthenticate_EachClientUnsupportedProtocol_Fail(SslProtocols protocol)
 {
     await Assert.ThrowsAsync<NotSupportedException>(() =>
     {
         return ClientAsyncSslHelper(protocol, SslProtocolSupport.SupportedSslProtocols);
     });
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:ClientAsyncAuthenticateTest.cs


示例10: SslTransportFactory

 public SslTransportFactory(X509Certificate certificate, SslProtocols protocols, ILayerFactory next, bool clientCertificateRequired)
 {
     _certificate = certificate;
     _protocols = protocols;
     _clientCertificateRequired = clientCertificateRequired;
     _next = next;
 }
开发者ID:et1975,项目名称:Nowin,代码行数:7,代码来源:SslTransportFactory.cs


示例11: TTlsServerSocketTransport

        public TTlsServerSocketTransport(
            int port,
            bool useBufferedSockets,
            X509Certificate2 certificate,
            RemoteCertificateValidationCallback clientCertValidator = null,
            LocalCertificateSelectionCallback localCertificateSelectionCallback = null,
            SslProtocols sslProtocols = SslProtocols.Tls12)
        {
            if (!certificate.HasPrivateKey)
            {
                throw new TTransportException(TTransportException.ExceptionType.Unknown,
                    "Your server-certificate needs to have a private key");
            }

            _port = port;
            _serverCertificate = certificate;
            _useBufferedSockets = useBufferedSockets;
            _clientCertValidator = clientCertValidator;
            _localCertificateSelectionCallback = localCertificateSelectionCallback;
            _sslProtocols = sslProtocols;

            try
            {
                // Create server socket
                _server = new TcpListener(IPAddress.Any, _port);
                _server.Server.NoDelay = true;
            }
            catch (Exception)
            {
                _server = null;
                throw new TTransportException($"Could not create ServerSocket on port {port}.");
            }
        }
开发者ID:nsuke,项目名称:thrift,代码行数:33,代码来源:TTlsServerSocketTransport.cs


示例12: ThrowOnNotAllowed

 public static void ThrowOnNotAllowed(SslProtocols protocols, bool allowNone = true)
 {
     if ((!allowNone && (protocols == SslProtocols.None)) || ((protocols & ~AllowedSecurityProtocols) != 0))
     {
         throw new NotSupportedException(SR.net_securityprotocolnotsupported);
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:SecurityProtocol.cs


示例13: ClientAsyncAuthenticate_MismatchProtocols_Fails

 public async Task ClientAsyncAuthenticate_MismatchProtocols_Fails(
     SslProtocols serverProtocol,
     SslProtocols clientProtocol,
     Type expectedException)
 {
     await Assert.ThrowsAsync(expectedException, () => ClientAsyncSslHelper(serverProtocol, clientProtocol));
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:ClientAsyncAuthenticateTest.cs


示例14: HttpsTestServer

 public HttpsTestServer(X509Certificate serverCertificate, SslProtocols acceptedProtocols = SslProtocols.Tls)
 {
     _serverCertificate = serverCertificate;
     _protocols = acceptedProtocols;
     _log = VerboseTestLogging.GetInstance();
     AuxRecordDetected = false;
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:HttpsTestServer.cs


示例15: AsyncStreamSocketSession

 public AsyncStreamSocketSession(Socket client, SslProtocols security, IPool<BufferState> bufferStatePool, bool isReset)
     : base(client)
 {
     SecureProtocol = security;
     m_BufferStatePool = bufferStatePool;
     m_IsReset = isReset;
 }
开发者ID:iraychen,项目名称:SuperSocket,代码行数:7,代码来源:AsyncStreamSocketSession.cs


示例16: SslStreamServer

        public SslStreamServer(
            Stream stream, 
            bool ownStream,
            X509Certificate serverCertificate,
            bool clientCertificateRequired,
            X509Chain caCerts,
            SslProtocols enabledSslProtocols,
            SslStrength sslStrength,
            bool checkCertificateRevocation,
            RemoteCertificateValidationHandler remote_callback)
            : base(stream, ownStream)
        {
            this.checkCertificateRevocationStatus = checkCertificateRevocation;
            this.remoteCertificateSelectionCallback = remote_callback;

            // Initialize the SslContext object
            InitializeServerContext(serverCertificate, clientCertificateRequired, caCerts, enabledSslProtocols, sslStrength, checkCertificateRevocation);
            
            ssl = new Ssl(sslContext);
            // Initialze the read/write bio
            read_bio = BIO.MemoryBuffer(false);
            write_bio = BIO.MemoryBuffer(false);
            // Set the read/write bio's into the the Ssl object
            ssl.SetBIO(read_bio, write_bio);
            read_bio.SetClose(BIO.CloseOption.Close);
            write_bio.SetClose(BIO.CloseOption.Close);
            // Set the Ssl object into server mode
            ssl.SetAcceptState();
        }
开发者ID:loonbg,项目名称:mooege,代码行数:29,代码来源:SslStreamServer.cs


示例17: TcpTransportSecurity

 public TcpTransportSecurity()
 {
     this.clientCredentialType = DefaultClientCredentialType;
     this.protectionLevel = DefaultProtectionLevel;
     this.extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
     this.sslProtocols = TransportDefaults.SslProtocols;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:TcpTransportSecurity.cs


示例18: SecureTcpServer

        public SecureTcpServer(int listenPort, X509Certificate serverCertificate,
            SecureConnectionResultsCallback callback,
            RemoteCertificateValidationCallback certValidationCallback)
        {
            if (listenPort < 0 || listenPort > UInt16.MaxValue)
                throw new ArgumentOutOfRangeException("listenPort");

            if (serverCertificate == null)
                throw new ArgumentNullException("serverCertificate");

            if (callback == null)
                throw new ArgumentNullException("callback");

            onAcceptConnection = new AsyncCallback(OnAcceptConnection);
            onAuthenticateAsServer = new AsyncCallback(OnAuthenticateAsServer);

            this.serverCert = serverCertificate;
            this.certValidationCallback = certValidationCallback;
            this.connectionCallback = callback;
            this.listenPort = listenPort;
            this.disposed = 0;
            this.checkCertifcateRevocation = false;
            this.clientCertificateRequired = false;
            this.sslProtocols = SslProtocols.Default;
        }
开发者ID:BGCX262,项目名称:zynchronyze-svn-to-git,代码行数:25,代码来源:SecureTcpServer.cs


示例19: SafeFreeCredentials

        public SafeFreeCredentials(X509Certificate certificate, SslProtocols protocols, EncryptionPolicy policy)
            : base(IntPtr.Zero, true)
        {
            Debug.Assert(
                certificate == null || certificate is X509Certificate2,
                "Only X509Certificate2 certificates are supported at this time");

            X509Certificate2 cert = (X509Certificate2)certificate;

            if (cert != null)
            {
                Debug.Assert(cert.HasPrivateKey, "cert.HasPrivateKey");

                using (RSAOpenSsl rsa = (RSAOpenSsl)cert.GetRSAPrivateKey())
                {
                    if (rsa != null)
                    {
                        _certKeyHandle = rsa.DuplicateKeyHandle();
                        Interop.libcrypto.CheckValidOpenSslHandle(_certKeyHandle);
                    }
                }

                // TODO (3390): Add support for ECDSA.

                Debug.Assert(_certKeyHandle != null, "Failed to extract a private key handle");

                _certHandle = Interop.libcrypto.X509_dup(cert.Handle);
                Interop.libcrypto.CheckValidOpenSslHandle(_certHandle);
            }

            _protocols = protocols;
            _policy = policy;
        }
开发者ID:shrutigarg,项目名称:corefx,代码行数:33,代码来源:SecuritySafeHandles.cs


示例20: HttpListenerBase

 /// <summary>
 /// Initializes a new instance of the <see cref="HttpListenerBase"/> class.
 /// </summary>
 /// <param name="address">IP Address to accept connections on</param>
 /// <param name="port">TCP Port to listen on, default HTTPS port is 443</param>
 /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param>
 /// <param name="certificate">Certificate to use</param>
 /// <param name="protocol">which HTTPS protocol to use, default is TLS.</param>
 /// <param name="requireClientCerts">True to require SSL client certificates</param>
 protected HttpListenerBase(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate,
                            SslProtocols protocol, bool requireClientCerts)
     : this(address, port, factory)
 {
     _certificate = certificate;
     _requireClientCerts = requireClientCerts;
     _sslProtocol = protocol;
 }
开发者ID:BGCX261,项目名称:zma-svn-to-git,代码行数:17,代码来源:HttpListenerBase.cs



注:本文中的SslProtocols类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SslStream类代码示例发布时间:2022-05-24
下一篇:
C# SslPolicyErrors类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap