[MonoDevelop] Recent gmail smtp RemoteCertificateChainErrors error

Guido Van Hoecke guivho at gmail.com
Mon Jul 1 17:34:06 UTC 2013


Hi,

Recently I get following error when trying to send mail from my Mono
ASP.net app via Gmail SMTP:

] SSL authentication error: RemoteCertificateChainErrors
] 
] Description: HTTP 500. Error processing request.
] 
] Stack Trace:
] 
] System.InvalidOperationException: SSL authentication error: RemoteCertificateChainErrors
] at System.Net.Mail.SmtpClient.<callback>m__4 (System.Object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors sslPolicyErrors) [0x00000] in <filename unknown>:0 
] at System.Net.Security.SslStream+<BeginAuthenticateAsClient>c__AnonStoreyC.<>m__A (System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Int32[] certErrors) [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.SslClientStream.OnRemoteCertificateValidation (System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Int32[] errors) [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.SslStreamBase.RaiseRemoteCertificateValidation (System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Int32[] errors) [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.SslClientStream.RaiseServerCertificateValidation (System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Int32[] certificateErrors) [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 
] at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
] at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
] at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 

I get this error in a web page that's been working for a couple of years
now.

Here's the method I use to create and send the mail:

        public static bool HtmlMail (string @from, string to, string bcc, string subject, IEnumerable<string> attachments, string htmlBody)
        {
            var mail = new MailMessage { From = new MailAddress (@from) };
            mail.To.Add (to);
            if (bcc.Length > 0)
                mail.Bcc.Add (bcc);
            mail.Subject = subject;
            mail.Body = htmlBody;
            mail.IsBodyHtml = true;
            foreach (var attachment in attachments) {
                mail.Attachments.Add (new Attachment (attachment));
            }
            var smtp = new SmtpClient {
                Host = SmtpServer, 
                Port = SmtpPort,
                EnableSsl = true,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(id, pw)
            };
            try {
                smtp.Send (mail);
                return true;
            }
            catch (WebException) {
                return false;
            }
        }

Where SmtpServer:SmtpPort are "smtp.gmail.com:587", and the (id, pw)
credentials are correct.

I have tried to follow the suggested approach in the second part of
http://stackoverflow.com/questions/9801224/smtpclient-with-gmail

] mozroots --import --ask-remove
] certmgr -ssl smtps://smtp.gmail.com:465

But the latter is not for tls (port 587) but for plain ssl (port 465)

I have no idea why this app suddenly generates
RemoteCertificateChainErrors

Any help is most welcome and would be sincerely appreciated!

With kind regards,


Guido

--
Isn't it ironic that many men spend a great part of their lives
avoiding marriage while single-mindedly pursuing those things that
would make them better prospects?


More information about the Monodevelop-list mailing list