Free Support Forum - aspose.com

Trying to connect to pop account with SSL

Hello,

I’m developing a VB app to connect to a pop account and I want to support SSL, but I’m getting an exception: "The remote certificate is invalid according to the validation procedure."

Is there a way to bypass this exception?

Thanks!

Don Tompkins

Hi Don,

Thank you for inquiry.

This error comes when the certificate is expired, invalid or self-signed. I have reproduced the same issue at my end and also logged it in our bug tracking system (ID: 25293). We will inform you when it gets fixed. Sorry for the inconvenience.

Hi Don,

Please use the overloaded constructor of Pop3Client class that required the callback method in arguments as below:

Pop3Client client = new Pop3Client(“host”, 995, “poptest@host”, “pwd”, RemoteCertificateValidationHandler);

// this event handler will be called when SSL certificate is verified
private static bool RemoteCertificateValidationHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
Console.WriteLine(“Ignored ssl”);
return true; //ignore the checks and go ahead
}

This helped me troubleshoot a certificate issue as well. Thanks!

saqib.razzaq:
Hi Don,

Please use the overloaded constructor of Pop3Client class that required the callback method in arguments as below:

Pop3Client client = new Pop3Client(“host”, 995, “poptest@host”, “pwd”, RemoteCertificateValidationHandler);


Does the argument in the constructor accomplish the same thing as the following?
Pop3Client client = new Pop3Client(“host”, 995, “poptest@host”, “pwd”);
System.Net.ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationHandler;

Hi Don,


Sorry for a delayed response.

I think both are serving the same purpose, as in both cases Remote Certificate Validation is handled to avoid the expire/invalid certificate validation.