I have one server and three clients in which a windows service is running with local system privileges. Clients and server are mutual authenticated using SSL over TCP and certificates (I'm using the SSLStream class C++\CLI http://msdn.microsoft.com/en-us/library/system.net.security.sslstream(v=vs.90).aspx#Y1124)
The problem is that i need three certificates (one for every client) because i'm authenticating the hosts. Now i want to authenticate the windows service and not the host so i can distribute the same certificate for every host.
Anyone know how can do it ?
--- EDIT 1 ---- To give you an example of what i want to do. In every Microsoft Office copy is deployed a certificate that is used to communicate with microsoft servers throught an encrypted/authenticated channel.
-- SOLVED --
As Jon said my problem was that the SslStream class perform standard validation which is included the hostname. I provided a custom RemoteCertificateValidationCallback and now it works.
bool ValidateServerCertificate( Object^ sender, X509Certificate^ certificate, X509Chain^ chain, SslPolicyErrors sslPolicyErrors ) {
Console::Write("[+] Validating server certificate: ");
// check certificate hash
if( certificate->GetCertHashString()->Equals("cert hash") ) {
Console::Write( "oK\n" );
return true;
}
Console::Write(" ERROR\n");
Console::WriteLine("[-] Hash doesn't match");
// Do not allow this client to communicate with unauthenticated servers.
return false;
}