Connecting to imap: remote certificate invalid.

Nov 19, 2011 at 8:29 AM
Edited Nov 19, 2011 at 8:31 AM

Hi,
I want to use the mailsystem-library to access an imap-account. I tried out the gmail-example posted here and it works fine. Using the same code to connect to another imap-server that can only be reached from our internal network and thus has no valid certificate always throws me an error (on doing .ConnectSsl) stating that the remote certificate is invalid ('Das Remotezertifikat ist laut Validierungsverfahren ungültig.').

Searching the internet I found how to override the server-certificate-validation:
Dim objCertOverride As New Email_Imap_CertificateOverride
Net.ServicePointManager.ServerCertificateValidationCallback = AddressOf objCertOverride.RemoteCertificateValidationCallback
RemoteCertificateValidationCallback is a function of the (self-written) class Email_Imap_CertificateOverride (with some parameters) that always returns true to accept any certificate. Anyway this did not help, I guess because the callback is not passed from the library to the application.

Next step was to dig myself into the sourcecode to better understand what's going on but as I'm doing mostly vb(a) this is quite hard for me. So what would be great is some instructions on how to accept any certificate connecting to an imap server (or ignore any certificate-related errors).

Thanks!
Georg