Im trying to get my mvc3 app to call a web service over https. Here is my code:
var basicHttpsBinding = new BasicHttpsBinding();
basicHttpsBinding.MaxBufferPoolSize = 104857600;
basicHttpsBinding.MaxBufferSize = 104857600;
basicHttpsBinding.MaxReceivedMessageSize = 104857600;
basicHttpsBinding.Security.Mode = System.ServiceModel.BasicHttpsSecurityMode.Transport;
basicHttpsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
var endpointAddress = new EndpointAddress("web service url.asmx");
var cfClient = new ChannelFactory<ws_name_webreqSoap>(basicHttpsBinding, endpointAddress);
ClientCredentials cc = cfClient.Endpoint.Behaviors.Find<ClientCredentials>();
cc.ClientCertificate.SetCertificate(
StoreLocation.LocalMachine,
StoreName.My,
X509FindType.FindByThumbprint,
"00000000000000000000000000000000000"
);
cfClient.CreateChannel();
var webServices = new ws_merit_webreqSoapClient(basicHttpsBinding, endpointAddress);
When i use "LocalMachine, i get the following error":
The client certificate is not provided. Specify a client certificate in ClientCredentials.
and when i use "currentUser" i get the following error:
Cannot find the X.509 certificate using the following search criteria: StoreName 'TrustedPeople', StoreLocation 'CurrentUser', FindType 'FindByThumbprint', FindValue
How can i fix the first error? What am i doing wrong?
Thanks