Microsoft Learn

Class System.Net.Security.TmschSslPolicyErrors

Represents the errors that occur during SSL/TLS certificate validation.

Syntax

public enum SslPolicyErrors

Namespace: System.Net.Security

Assembly: System (in System.dll)

Members

None

No errors occurred.

RemoteCertificateNameMismatch

The certificate is for a different name than the server name specified in the request.

RemoteCertificateChainErrors

The certificate chain is invalid, meaning the certificate authority is not trusted or the certificate is expired.

RemoteCertificateNotAvailable

The server did not provide a certificate.

Remarks

The SslPolicyErrors enumeration is used by the System.Net.Security.RemoteCertificateValidationCallback delegate to indicate the errors that occurred when validating an SSL or TLS certificate on the server.

When establishing an SSL/TLS connection, the client validates the server's certificate. If any errors are detected during this validation process, the RemoteCertificateValidationCallback delegate is invoked. This delegate receives an X509Certificate object representing the server's certificate and an SslPolicyErrors value indicating the specific errors encountered.

Developers can use this information to decide whether to trust the certificate and proceed with the connection or to abort the connection.

Tip

In production environments, it is highly recommended to validate the entire certificate chain and ensure that the certificate name matches the server's hostname. Accepting connections with RemoteCertificateNameMismatch or RemoteCertificateChainErrors can expose your application to man-in-the-middle attacks.