I have the following C# client code to check incoming certificate in a SSL communication(with WCF) :
private bool ValidateClientCertificate(System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
_certificateValid = sslPolicyErrors == System.Net.Security.SslPolicyErrors.None ? true : false;
return true;
}
When entering the method I can see that the sslPolicyErrors is set to RemoteCertificateNameMismatch?
I have created the server certificate like this :
- Create MyCert Root CA on Server 1
- Request Subordinate CA certificate created at Server 2 and sent to server 1 to be issued
- Install the issued MyCert CA(Subordinate CA) certificate on server 2
- Request a function cert at Server 1 from Server 2 with MyCert CA
- Install MyCert Services Server 1 on Server 1 and bind it to the service
- Install MyCert Root CA and MyCert CA on client and check that it validates the entire chain of 3.
- Start client and connect to the service on server 1
Because the request of the MyCert Services Server 1 was created at Server 1 where it also was installed it I should not get the SSL error, right? Is there any attribute or something that need to be set on the function cert that validates against the Server 1?
From what I understand the name does not have to be the same as the server?
Edit : I create a new function certificate and set the CN to the DNS name of the server itself. Each client computer has a host file that points this CN name to a the specific IP of the server. I do however still get the same SSL Policy Error in the ValidateClientCertificate method? Exactly what setting is needed on the certificate to pass the validation?