当前位置: 首页>>代码示例>>C#>>正文


C# SslProtocols类代码示例

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


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


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