Getting CryptographicException on Pop3Client.Connect()

I’m trying simply to connect to GMail to retrieve POP3 mail via SSL. My code instantiates a Pop3Client and initializes it the same as examples I’ve seen posted. Yet, immediately in the Connect() call, a CryptographicException is thrown with the message “The handle is invalid.” I’ve verified that all the client properties are set as expected at the time of the Connect() call. Am I missing something?


`

private void getPopEmail(string Server, string UserName, string Password, int? Port, bool useSsl)

{

// Create POP3 client

Aspose.Email.Pop3.Pop3Client client;

client = new Aspose.Email.Pop3.Pop3Client() { Host = Server, Username = UserName, Password = Password };

client.Port = (Port.HasValue && Port.Value > 0) ? Port.Value : (useSsl ? 995 : 110); // Use default POP or SSL-POP port if none specified

if (useSsl)

{

// Settings required for SSL enabled POP3 servers

client.EnableSsl = true;

client.SecurityMode = Aspose.Email.Pop3.Pop3SslSecurityMode.Implicit;

}


// Assume certificates presented by SSL servers are good, as users entered their own mail server data

// The CryptographicException is thrown with or without this line of code

ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });


client.Connect(); // Exception thrown here

client.Login();

...

`

Hi,

Thanks for writing to Aspose.Email support team.

I am afraid to inform that I could not reproduce the issue using my test account credentials in your sample code. I used your code as given below:

static void Main(string[] args)
{
getPopEmail(“[pop.gmail.com](http://pop.gmail.com/)”, “username”, “password”, 995, true);
}
static private void getPopEmail(string Server, string UserName, string Password, int? Port, bool useSsl)
{
// Create POP3 client
Aspose.Email.Pop3.Pop3Client client;
client = new Aspose.Email.Pop3.Pop3Client() { Host = Server, Username = UserName, Password = Password };
client.Port = (Port.HasValue && Port.Value > 0) ? Port.Value : (useSsl ? 995 : 110); // Use default POP or SSL-POP port if none specified
if (useSsl)
{
// Settings required for SSL enabled POP3 servers
client.EnableSsl = true;
client.SecurityMode = Aspose.Email.Pop3.Pop3SslSecurityMode.Implicit;
}
// Assume certificates presented by SSL servers are good, as users entered their own mail server data
// NO CryptographicException is thrown with or without this line of code
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });

client.Connect(); // NO Exception thrown here
client.Login();
}

I tried above code with and without “ServicePointManager.ServerCertificateValidationCallback” but no issue was observed.

Please use the latest assembly of Aspose.Email for .NET 2.6.0 and if still this issue persists, provide us credentials of some test account on Gmail which can be used to re-produce the issue here as it will help us to assist you as soon as possible.