System.Net.Security.SslValidationTypeResult
Overview
Represents the result of an SSL validation operation. This enumeration is used to indicate whether an SSL certificate is valid or why it failed validation.
When establishing a secure connection using SSL/TLS, the client typically validates the server's certificate. The validation process involves checking the certificate's authenticity, trust chain, expiration date, and other criteria. The SslValidationTypeResult enumeration provides a structured way to report the outcome of these checks.
Syntax
Members
- Success: The SSL certificate validation was successful.
- Untrusted: The SSL certificate is not trusted by the local machine's trusted root certificate authorities.
- Expired: The SSL certificate has expired.
- InvalidHostName: The SSL certificate's host name does not match the host name of the server.
- InvalidSignature: The SSL certificate's signature is invalid.
- Revoked: The SSL certificate has been revoked by the issuing Certificate Authority (CA).
- Other: An unspecified validation error occurred.
Remarks
This enumeration is often used in conjunction with the System.Net.Security.RemoteCertificateValidationCallback delegate. This callback allows developers to provide custom logic for validating server certificates, going beyond the default system checks. For example, you might use it to validate against a specific set of trusted certificates or to implement domain-specific validation rules.
When implementing a custom validation callback, you will receive an X509Certificate object representing the server's certificate and the validation results. Your callback should return true if the certificate is acceptable and false otherwise. The SslValidationTypeResult members help in determining the appropriate return value based on the validation outcome.
Example
The following example demonstrates how to use a custom RemoteCertificateValidationCallback to inspect the validation result.
Requirements
Namespace: System.Net.Security
Assembly: System.Net.Primitives (in .NET Core, .NET 5+)
Assembly: System (in .NET Framework)