首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >例外情况:未提供客户端证书。

例外情况:未提供客户端证书。
EN

Stack Overflow用户
提问于 2012-01-13 16:40:25
回答 1查看 15.2K关注 0票数 6

我正在尝试用安全性配置WCF服务。我已经生成了两个存储在LocalComputer\Personal证书中的证书(用于服务器和客户端)。我的配置是:

服务器:

代码语言:javascript
复制
<netTcpBinding>
   <binding name="defaultBinding">
      <security mode="Transport">
         <transport clientCredentialType="Certificate"/>
      </security>
   </binding>
</netTcpBinding>

<service name="..." behaviorConfiguration="serviceBehavior">
   <endpoint address="..." binding="netTcpBinding" bindingConfiguration="defaultBinding" contract="...">
      <identity>
        <dns value="ClientSide"/>
      </identity>
    </endpoint>
 </service>

 <behavior name="serviceBehavior">
    <serviceCredentials>
       <serviceCertificate storeLocation="LocalMachine" storeName="My" findValue="ServerSide" x509FindType="FindBySubjectName"/>
       <clientCertificate>
          <authentication certificateValidationMode="None" revocationMode="NoCheck"/>
       </clientCertificate>
    </serviceCredentials>
 <behavior>

客户端:

代码语言:javascript
复制
<netTcpBinding>
   <binding name="defaultBinding">
      <security mode="Transport">
         <transport clientCredentialType="Certificate"/>
      </security>
   </binding>
</netTcpBinding>

<endpoint name="..." binding="netTcpBinding" bindingConfiguration="defaultBinding" contract="..."
            behaviorConfiguration="endpointBehavior">
  <identity>
    <dns value="ServerSide"/>
  </identity>
</endpoint>

 <behavior name="endpointBehavior">
    <clientCredentials>
       <serviceCertificate>
          <authentication certificateValidationMode="None" revocationMode="NoCheck"/>
       </serviceCertificate>
       <clientCertificate storeLocation="LocalMachine" storeName="My" findValue="ClientSide" x509FindType="FindBySubjectName"/>
    </clientCredentials>
 <behavior>

我得到了例外情况:没有提供客户端证书。在ClientCredentials中指定客户端证书

我试过很多教程,但都没有用。有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-23 14:33:21

答案实际上是例外。你没有客户证书。为客户端证书定义服务证书。

代码语言:javascript
复制
<clientCredentials>
       <serviceCertificate>
          <authentication certificateValidationMode="None" revocationMode="NoCheck"/>
       </serviceCertificate>
       <clientCertificate storeLocation="LocalMachine" storeName="My" findValue="ClientSide" x509FindType="FindBySubjectName"/>
    </clientCredentials>

但实际上您应该为客户端定义一个客户端证书。

代码语言:javascript
复制
<system.serviceModel>
   <behaviors>
      <endpointBehaviors>
         <behavior name="endpointBehavior">
            <clientCredentials>
               <clientCertificate storeLocation="LocalMachine" storeName="My" findValue="ClientSide" x509FindType="FindBySubjectName" />
               <serviceCertificate>
                  <authentication certificateValidationMode="None" revocationMode="NoCheck" />
               </serviceCertificate>
            </clientCredentials>
         </behavior>
      </endpointBehaviors>
   </behaviors>
</system.serviceModel>

这至少应该解决您的The client certificate is not provided. Specify a client certificate in ClientCredentials异常。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8854016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档