none
WCF 客户端找不到证书 RRS feed

  • 问题

  • 错误提示:

    未提供客户端证书。请在 ClientCredential 中指定一个客户端证书。

    app.config配置:

    <system.serviceModel>
          <behaviors >
            <endpointBehaviors >
              <behavior name ="clientCredentialBehavior" >
                <clientCredentials >
                  <clientCertificate storeName ="My" storeLocation ="LocalMachine" findValue ="Dispatch.Client" x509FindType ="FindBySubjectName"/>
                  <serviceCertificate >
                    <authentication certificateValidationMode ="ChainTrust"/>
                  </serviceCertificate>
                </clientCredentials>
              </behavior>
            </endpointBehaviors>
          </behaviors>
          <bindings>
            <basicHttpBinding>
              <binding name="BasicHttpBinding_ICertService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="Transport">
                  <transport clientCredentialType="Certificate" proxyCredentialType="None"
                    realm="" />
                  <message clientCredentialType="Certificate" algorithmSuite="Default" />
                </security>
              </binding>
            </basicHttpBinding>
          </bindings>
          <client>
            <endpoint address="https://localhost:1702/CertService/Service.svc"
              binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICertService"
              contract="ServiceReference.ICertService" name="BasicHttpBinding_ICertService" />
          </client>
        </system.serviceModel>

    2011年2月17日 3:59

答案

全部回复

  • 问题出在这一段:

    <clientCertificate storeName ="My" storeLocation ="LocalMachine" findValue ="Dispatch.Client" x509FindType ="FindBySubjectName"/>

     

    看一下,你制作的客户端证书,和你这里设置的查找条件是否匹配。

    从错误来看,基本上是上面某个条件设置错了。

    证书的主题名称是Dispatch.Client吗?

    另外是不是存储在LocalMachine本地计算机 区域里


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    微软WCF中文技术论坛
    微软WCF英文技术论坛

    Windows Azure中文技术论坛

    2011年2月19日 4:06
    版主
  • 你好,

    你设置的EndpointBehavior没有应用到你的Endpoint上,需要通过Endpoint.BehaviorConfiguration属性来设置EndpointBehavior

     <endpoint address="https://localhost:1702/CertService/Service.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICertService"
    behaviorConfiguration="clientCredentialBehavior"
    contract="ServiceReference.ICertService" name="BasicHttpBinding_ICertService" />


    Mog Liang
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    2011年2月22日 7:20