views:

63

answers:

2

Is there way to attach client side SSL file (.pfx) file in WCF binding? I don't want to use certificate store.

A: 

This way you can bind SSL client certificate in the code

    WSHttpBinding myBinding = new WSHttpBinding();
        myBinding.Security.Mode = SecurityMode.Transport;
        myBinding.Security.Transport.ClientCredentialType =
            HttpClientCredentialType.Certificate;

    webServiceProxyInstance.ClientCredentials.ClientCertificate.SetCertificate(
            StoreLocation.CurrentUser,
            StoreName.My,
            X509FindType.FindByThumbprint,
            "fa f9 2d e3 fb 01 18 db 24 2a 49 56 ff f5 8b 7f e0 59 d4 98");
amz
That's actually still using the windows certificate store, not a certificate in a pfx file.
tomasr
A: 

This should work

webServiceProxyInstance.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2("path to the pfx file", "password to open the private key");
amz