我正在尝试调用WCF服务。我创建了一个自签名证书并安装在我的localmachine \ personnal \ certificates中,我也在我的部分中添加了。但我不明白为什么会出现这个错误。
这是我的web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpoint">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://abcdxyz.abc.syntax.com/TestCCService.svc"
binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
contract="TestCCService.ITestCCService" name="wsHttpEndpoint" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehavior">
<clientCredentials>
<clientCertificate findValue="abc.mymachine.name.com" x509FindType="FindBySubjectName"
storeLocation="LocalMachine" storeName="My" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
但是当我尝试调用我的服务方法时抛出错误 “未提供客户端证书。在ClientCredentials中指定客户端证书。”
感谢您提出解决此错误的建议?
答案 0 :(得分:12)
我忘了包含behaviorConfiguration =“CustomBehavior”
<endpoint address="https://abcdxyz.abc.syntax.com/TestCCService.svc"
binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
contract="TestCCService.ITestCCService" name="wsHttpEndpoint" **behaviorConfiguration="CustomBehavior"** />
现在正在工作。
感谢您的帮助