Exception when trying to authenticate SSL connection

0

On my client when attempting to authenticate an SSL connection, an exception of type AuthenticationException is raised. The errors found in the certificate are RemoteCertificateNameMismatch and RemoteCertificateChainErrors .

The code used to authenticate:

sslStream.AuthenticateAsClient(serverName);

How can I resolve this exception?

    
asked by anonymous 11.06.2014 / 14:56

1 answer

0

Let's break the problem into parts.

Regarding the error RemoteCertificateNameMismatch , this is due to the fact that the name that must pass AuthenticateAsClient(...) is the name of the server. That is, if the server is localhost , you should pass that name this way:

sslStream.AuthenticateAsClient("localhost");

If you are generating your own certificate, you must ensure that the name that passes to AuthenticateAsClient is the same as that in the "CN = [server name]" option.

For RemoteCertificateChainErrors , if you are generating your own certificate, the algorithm that validates the certificate may not trust your certificate because it is not in a secure location.

One way to resolve the problem is to install the certificate in the certificate store of your computer or use the following code (source:

11.06.2014 / 16:48