I installed hmailserver 5.3.2 and configured it. It usually receives and sends, but I wanted to use it to send letters from an .net / C # application located on another server, and for this I wanted to use SSL. Before that, the application was configured to send email via gmail, on port 587, and it worked fine, but now we want to use our own mail server. First, we configured the application to connect smtp.domain.com to port 25, and it works, it sends an email.
Then we created a self-signed certificate to check if we can send a message through a secure channel. I created a certificate using openSSL that sets the common name as: mail.domain.com, smtp.domain.com, * .domain.com, domain.com. I opened port 587 on the firewall and configured hmailserver to use a certificate for incoming connections to this port. None of the certificates I created (I tried one, and then created another one, etc.), throwing the following (general) exception in Application:
System.Exception: _COMPlusExceptionCode = -532459699
Of course, I also tried to connect via telnet: telnet smtp.domain.com 587, and I just got a blank screen. This is not a firewall problem, because when I disable ssl on port 587, I can connect normally. Looking at the log, I do not even see an attempt to connect when using 587 with SSL.
I already checked the following questions: Getting SmtpClient to work with a self-signed SSL certificate and Using a self-signed certificate with .NET HttpWebRequest / Response , but this did not solve my problem. The approach with ServerCertificateValidationCallback had no effect.
I tried with ports 25 (which is also suggested in one of the questions above), 465, 587, and the same thing happens with all 3: the initial handshake (SYN / SYN-ACK / ACK) and after about 80 seconds the connection is closed (FIN ), there is nothing between them.
Should I install this certificate somewhere so that the .net application considers it reliable? I mean, I already installed it as a trusted root certification authority and could verify by running mmc, so I have no idea where to go now ...
Thanks for the help!
PS: Not sure if this applies to ServerFault, since it applies to a C # application, but also to a mail server ...
EDIT: Code Example:
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; SmtpClient mailClient = new SmtpClient("smtp.domain.com"); mailClient.Credentials = new NetworkCredential(" username@domain.com ", "pwd"); mailClient.Port = 587; mailClient.EnableSsl = true; MailMessage mailMessage = new MailMessage("mailAddressFrom", "mailAddressTo", "subject", "body"); mailMessage.IsBodyHtml = true; mailClient.Send(mailMessage);
EDIT 2: Journal (at the suggestion of Ramunas):
"TCPIP" 3588 "2010-06-23 10:02:49.685" "TCPConnection - Posting AcceptEx on 0.0.0.0:465" "DEBUG" 3588 "2010-06-23 10:02:49.809" "Creating session 24039" "TCPIP" 772 "2010-06-23 10:04:29.639" "TCPConnection - SSL handshake with client failed. Error code: 2, Message: End of file, Remote IP: X" "DEBUG" 772 "2010-06-23 10:04:29.639" "Ending session 24039"