Search code examples
c#ssltcpssl-certificatesslstream

Is possible to use self signed certificate for testing on different machines?


I created self signed certificate for test purposes. I used this post: SSLStream example - how do I get certificates that work? I use code on client like this.

AuthenticateAsClient("testName", null, SslProtocols.Default, false);

and on server:

BeginAuthenticateAsServer(certificate, false, SslProtocols.Default, false, EndAuthenticate, obj);

If I start on same machine where certificate it's ok. But when I move client on other machine I get RemoteCertificateChainErrors.

Does somebody know should I use some "real" certificate or I should add some options to my current?

PS: Cer has All application policies, All issuance policies Pfx has All application policies


Solution

  • It should work from other machine too. Things to check:

    1. Did you import RootCATest.cer into Computer store's Trusted Root Certification Authorities on new client machine?
    2. Is a server name (first param in AuthenticateAsClient() - in your example "testName") equal to CN in subject of server certificate?

    UPDATE: It should work from other machine too, but you have to import your self-signed root CA cert to its Trusted Root Certification Authorities store. Your custom CA certificate is not trusted by default on the client. If you order certificate from trusted CA, you do not have to import anything on the client because their CAs are already there. Trusted CA do some checks (if you are an owner of the domain etc.) before they issue the SSL certificate to you.