OpenPOP.POP3 with IIS SSL Certificate

I am using OpenPOP I am trying to get mail from an exchange server on a server. This is my code.

 popClient.Connect(host.Host, (int)host.Port, (bool)host.Ssl);
 popClient.Authenticate(host.Username, host.Password);

Prodlem is an SSL certificate created in iis 7 and is not a valid certificate, is there any way around this.

This gives me an error, the remote certificate is not valid according to the verification procedure.

+3
source share
2 answers

Yes, there is a way. This requires a slight code change, this is the POPClient class.

1. SslStream, , , .

SslStream stream = new SslStream(clientSocket.GetStream(), false); 

POPClient, Connect

SslStream stream = new SslStream(clientSocket.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

2. , , , true:

public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{         
    return true;  // force the validation of any certificate
}

, , msdn.

+6

OpenPop. , , , , , , . TODO .

/Kasper (foens)

+2

Source: https://habr.com/ru/post/1775422/


All Articles