I'm using a test email server to test out my code in SSL environment. I used the following command to create a self signed root and a signed certificate.
I wrote a simple test program using SmtpClient to send test email and the code is as follow:
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage(tFrom.Text, tTo.Text);
mm.Subject = tSubject.Text;
mm.Body = tBody.Text;
SmtpClient client = new SmtpClient(tSmtp.Text, Convert.ToInt32(tPort.Text));
client.UseDefaultCredentials = false;
if (!String.IsNullOrEmpty(tPass.Text) && !String.IsNullOrEmpty(tUser.Text))
{
client.EnableSsl = true;
client.Credentials = new NetworkCredential(tUser.Text, tPass.Text);
}
client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
client.SendAsync(mm, null);
On my server (Smtp4Dev) I have it set to accept TLS connection
On my client machine I have the following:
Yet, whenever I send an email I keep getting the error as follow on the server log:
220 Ready to start TLS
Session ended abnormally.
System.NotSupportedException: The server mode SSL must use a certificate with the associated private key.
If I tried this without SSL then I can receive my email fine. I tried to add the certificate under Personal and Trusted Root Certification but same error still occur. I am very new to SSL so I hope you can point me in the right direction.