AuthenticationScheme Enum

Namespace: System.Net.Security

Assembly: System.Net.Primitives.dll

Specifies the authentication scheme to be used for Secure Socket Layer (SSL) or Transport Layer Security (TLS) authentication.

Members

Member name Value Description
None 0 No authentication is performed.
Ssl3 1 SSL version 3.0 authentication.
Tls 2 Transport Layer Security (TLS) authentication.
Tls10 4 TLS version 1.0 authentication.
Tls11 8 TLS version 1.1 authentication.
Tls12 16 TLS version 1.2 authentication.
Default Tls12 The default authentication scheme, which is typically the highest supported TLS version.

Remarks

The AuthenticationScheme enumeration is used to specify the authentication protocol to be used for SSL or TLS communication. When creating an SslStream object, you can specify the desired authentication scheme. This allows you to control the level of security and compatibility with different server and client configurations.

The Default value is a convenient way to select the most secure and widely supported TLS version available on the system. It's generally recommended to use Default unless you have specific compatibility requirements that necessitate a particular older version.

See Also

Example

The following code example demonstrates how to specify the AuthenticationScheme.Tls12 when creating an SslStream.

// Assuming you have an existing NetworkStream named 'innerStream'
// and you want to use TLS 1.2 for authentication.
var clientCertificate = new X509Certificate2("client.pfx", "password"); // Replace with your certificate path and password

var sslStream = new SslStream(innerStream, false,
    new RemoteCertificateValidationCallback(ValidateServerCertificate),
    new LocalCertificateSelectionCallback(SelectClientCertificate));

// You can specify the authentication scheme during initialization or when calling AuthenticateAsClientAsync
// For example, when calling AuthenticateAsClientAsync:
await sslStream.AuthenticateAsClientAsync("server.example.com", // Target host name
                                        new X509CertificateCollection(clientCertificate),
                                        SslProtocols.Tls12, // Explicitly set TLS 1.2
                                        false);

// ... rest of your secure communication logic