Assuming you are using a duplex channel, you can download a certificate from a file as follows:
//Load certificate file with private key var certificate = new X509Certificate2("c:\certificate.pfx", "password"); //Configure your server by to use certificate, for example: var host = new ServiceHost(typeof(YourService), new Uri("Your service uri")); host.Credentials.ServiceCertificate.Certificate = certificate; //configure your server to accept client certificate , accept all //certificate in this case, or you can assign it to the public key file host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
In your client code, upload the certificate in the same way as above
I think everything should be in order from now on. Just remember that if you download from a file, you need to download the .pfx file generated by pvk2pfx.exe, it has both a private key and a public key. Otherwise, WCF is confused with where to look for the private key.
source share