hello, in our non-gui application we want to use explicit security on imap-connection. The validation of the server certificate should be done in hidden mode, without knowing the hostname to be set to the TlsParameters.CommonName property. Is this possible and how? At the moment we always get an error by using the CertificateRequestHandler.StoreSearch

Error: Server certificate was rejected by the verifier because the certificate's common name '*.genotec.ch' does not match the hostname 'mail.myfactoryschweiz.ch'

asked 25 May '11, 11:33

martin's gravatar image

martin
745
accept rate: 0%


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);
link

answered 25 May '11, 13:26

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117
accept rate: 28%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×76
×8

Asked: 25 May '11, 11:33

Seen: 1,061 times

Last updated: 25 May '11, 13:26