Click or drag to resize
MimeKit

MailServiceDefaultServerCertificateValidationCallback Method

The default server certificate validation callback used when connecting via SSL or TLS.

Namespace:  MailKit
Assembly:  MailKit (in MailKit.dll) Version: 2.3.0
Syntax
C#
public static bool DefaultServerCertificateValidationCallback(
	Object sender,
	X509Certificate certificate,
	X509Chain chain,
	SslPolicyErrors sslPolicyErrors
)

Parameters

sender
Type: SystemObject
The object that is connecting via SSL or TLS.
certificate
Type: System.Security.Cryptography.X509CertificatesX509Certificate
The server's SSL certificate.
chain
Type: System.Security.Cryptography.X509CertificatesX509Chain
The server's SSL certificate chain.
sslPolicyErrors
Type: System.Net.SecuritySslPolicyErrors
The SSL policy errors.

Return Value

Type: Boolean
true if the certificate is deemed valid; otherwise, false.
Remarks

The default server certificate validation callback considers self-signed certificates to be valid so long as the only error in the certificate chain is an untrusted root.

Security note Security Note
It should be noted that self-signed certificates may be an indication of a man-in-the-middle (MITM) attack and so it is recommended that the client implement a custom server certificate validation callback that presents the certificate to the user in some way, allowing the user to confirm or deny its validity.
See Also