SSL certificate is issued for a specific name.
When connecting to a SMTP server, name on the certificate presented by the server, must match the server name you have used when connecting with SMTP client.
When you are using IP address, they obviously don't match.
You need to use ServerCertificateValidate callback and accept the certificate yourself:
using (Smtp smtp = new Smtp())
{
smtp.ServerCertificateValidate += ValidateCertificate;
smtp.ConnectSSL("192.168.0.1");
....
}
private static void ValidateCertificate(
object sender,
ServerCertificateValidateEventArgs e)
{
const SslPolicyErrors ignoredErrors =
SslPolicyErrors.RemoteCertificateChainErrors
| SslPolicyErrors.RemoteCertificateNameMismatch;
if ((e.SslPolicyErrors & ignoredErrors) != 0)
{
e.IsValid = true;
return;
}
e.IsValid = false;
}