WCF错误未提供客户端证书.在ClientCredentials中指定客户端证书

问题描述:

我正在尝试调用WCF服务.我创建了一个自签名证书,并将其安装在本地计算机\ personnal \ certificates中,并在本节中进行了添加.但是我不明白为什么会出现此错误.

I am trying to call a WCF service .I created a selfsigned certificate and installed in my localmachine \personnal \certificates , and also I added that in my section .But I don't understand why this error is .

这是我的web.config

Here is my 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中指定客户端证书."

but when I try to call my service method its throwing errors "The client certificate is not provided. Specify a client certificate in ClientCredentials."

赞赏您的建议来解决此错误吗?

Appreciate your suggestions to resolve this error ?

我忘了包含behaviorConfiguration ="CustomBehavior"

I forgot to include behaviorConfiguration="CustomBehavior"

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

及其现在正在工作.

谢谢您的帮助