【问题标题】:WCF error The client certificate is not provided. Specify a client certificate in ClientCredentialsWCF 错误 未提供客户端证书。在 ClientCredentials 中指定客户端证书
【发布时间】:2013-03-27 01:33:07
【问题描述】:

我正在尝试调用 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 中指定客户端证书。”

感谢您提出的解决此错误的建议?

【问题讨论】:

  • WCF 声称您没有与“abc.mymachine.name.com”匹配的客户端证书;你确定你创建的正确吗?
  • 是的,我已经安装了“abc.mymachine.name.com”证书。

标签: wcf wshttpbinding


【解决方案1】:

我忘了包括 behaviorConfiguration="CustomBehavior"

<endpoint address="https://abcdxyz.abc.syntax.com/TestCCService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
                contract="TestCCService.ITestCCService" name="wsHttpEndpoint" **behaviorConfiguration="CustomBehavior"** />

它现在可以工作了。

感谢您的帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-18
    • 2012-12-25
    • 1970-01-01
    • 2012-02-09
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 1970-01-01
    相关资源
    最近更新 更多