本文整理汇总了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());
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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");
}
示例9: ClientAsyncAuthenticate_EachClientUnsupportedProtocol_Fail
public async Task ClientAsyncAuthenticate_EachClientUnsupportedProtocol_Fail(SslProtocols protocol)
{
await Assert.ThrowsAsync<NotSupportedException>(() =>
{
return ClientAsyncSslHelper(protocol, SslProtocolSupport.SupportedSslProtocols);
});
}
示例10: SslTransportFactory
public SslTransportFactory(X509Certificate certificate, SslProtocols protocols, ILayerFactory next, bool clientCertificateRequired)
{
_certificate = certificate;
_protocols = protocols;
_clientCertificateRequired = clientCertificateRequired;
_next = next;
}
示例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}.");
}
}
示例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);
}
}
示例13: ClientAsyncAuthenticate_MismatchProtocols_Fails
public async Task ClientAsyncAuthenticate_MismatchProtocols_Fails(
SslProtocols serverProtocol,
SslProtocols clientProtocol,
Type expectedException)
{
await Assert.ThrowsAsync(expectedException, () => ClientAsyncSslHelper(serverProtocol, clientProtocol));
}
示例14: HttpsTestServer
public HttpsTestServer(X509Certificate serverCertificate, SslProtocols acceptedProtocols = SslProtocols.Tls)
{
_serverCertificate = serverCertificate;
_protocols = acceptedProtocols;
_log = VerboseTestLogging.GetInstance();
AuxRecordDetected = false;
}
示例15: AsyncStreamSocketSession
public AsyncStreamSocketSession(Socket client, SslProtocols security, IPool<BufferState> bufferStatePool, bool isReset)
: base(client)
{
SecureProtocol = security;
m_BufferStatePool = bufferStatePool;
m_IsReset = isReset;
}