jeudi 7 novembre 2013

“The remote certificate is invalid according to the validation procedure.” using Gmail SMTP server

Lors de l'envoi d'un mail avec C# Je suis tombé sur l'erreur suivante :


“The remote certificate is invalid according to the validation procedure.” using Gmail SMTP server

j'ai trouvé la solution sur internet

et plus précisemment:

As a workaround, you can switch off certificate validation
put this code somewere before smtpclient.Send():
ServicePointManager.ServerCertificateValidationCallback 
 = delegate(object s, X509Certificate certificate, X509Chain chain, 
 SslPolicyErrors sslPolicyErrors) {  
return true; };