Class SmtpCertificateValidation
Provides SSL certificate validation callbacks for use with CertificateValidationCallback.
Inherited Members
Namespace: DRIT.Mail.Rfc.Smtp
Assembly: DRIT.Mail.dll
Syntax
public static class SmtpCertificateValidation
Methods
View SourceAcceptAll(object, X509Certificate?, X509Chain?, SslPolicyErrors)
Accepts any certificate, regardless of validity. This callback disables all certificate validation and should only be used in testing. Never use in production.
Declaration
public static bool AcceptAll(object sender, X509Certificate? certificate, X509Chain? chain, SslPolicyErrors sslPolicyErrors)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | |
| X509Certificate | certificate | |
| X509Chain | chain | |
| SslPolicyErrors | sslPolicyErrors |
Returns
| Type | Description |
|---|---|
| bool | Always |
ValidateChainAndHostname(object, X509Certificate?, X509Chain?, SslPolicyErrors)
Validates the server certificate chain and hostname. This is the production-safe default. It accepts the certificate only when the platform has validated both the chain and the hostname match.
When SmtpClient calls
AuthenticateAsClient(string) with the
target hostname, the platform already checks that the
certificate's Subject CN or Subject Alternative Names match
the specified hostname. If everything passes,
sslPolicyErrors will be
None.
Declaration
public static bool ValidateChainAndHostname(object sender, X509Certificate? certificate, X509Chain? chain, SslPolicyErrors sslPolicyErrors)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | |
| X509Certificate | certificate | |
| X509Chain | chain | |
| SslPolicyErrors | sslPolicyErrors |
Returns
| Type | Description |
|---|---|
| bool |
|