问题
I need to access web services of one of our partners. Their services are secured with both a Client Certificate and Basic Authentication. I'm using WCF with BasicHttpBinding.
I am able to hook up the cert using Transport level security. I know the cert is working because I'm no longer getting a 403 error, but I am getting a 401 because I can't pass the credentials along with the transport. From what I can see, I can only have one type of transport security scheme.
How can I achieve this?
<security mode="Transport">
<transport type="Certificate" />
<transport type="Basic" />
</security>
Thanks
回答1:
Did you tried to pass credential at message level. Your config should look like:
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
and then in the code
WebServiceProxy objClient = new WebServiceProxy ();
objclient.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "clientCert");
objClient.ClientCredentials.UserName.UserName = "username";
objClient.ClientCredentials.UserName.Password = "Password";
来源:https://stackoverflow.com/questions/8214259/wcf-client-with-client-certificate-and-basic-authentication