The simplest way for this case is to write an ICertificateVerifier
implementation which ignores the HostName/CommonName as follows:
public class MyCertificateVerifier : ICertificateVerifier
{
public TlsCertificateAcceptance Verify(TlsSocket socket, string commonName, CertificateChain certificateChain)
{
return CertificateVerifier.Default.Verify(socket, null, certificateChain);
}
}
Sample of use with the Imap
object follows:
TlsParameters parameters = new TlsParameters();
parameters.CertificateVerifier = new MyCertificateVerifier();
Imap client = new Imap();
client.Connect("mail.myfactoryschweiz.ch", Imap.DefaultPort, parameters, ImapSecurity.Explicit);