andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

The remote certificate is invalid according to the validation procedure. #40

Closed premiumpixel closed 12 years ago

premiumpixel commented 12 years ago

Hey andy, I'm trying to use your library with a imap and pop server to get mail. I'm getting this exception "Authentication Exception was unhandled by user code: The remote certificate is invalid according to the validation procedure." What can I do to skip this validation procedure?

Thanks much for your work, Florian

andyedinborough commented 12 years ago

Try adding this to your code (C#):

System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, err) => true;
piher commented 12 years ago

Hi i'm facing the same issue; Did that work for you premiumpixel ? I tried adding it both in my code before creating the imap client and directly into the library's connect method and none of them solved the problem.

piher commented 12 years ago

var sslStream = new System.Net.Security.SslStream(_Stream, false, (sender, cert, chain, err) => true); did the trick. I think this issue will happen on many small providers. Should a "bool skipCertificateValidation" arg be added to the connect method ?

premiumpixel commented 12 years ago

@piher: Thanks much. That solved it. And I totally agree with your suggestion.