1

我知道这是一个非常常见的情况,但经过两天的搜索,我仍然没有找到解决这个问题的方法。

我有一个 WCF 服务和一个客户端(网站),使用 SSL 和客户端证书。

相关服务配置部分:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="HOLBinding">
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="HOLServiceBehaviour">
          <serviceCredentials>
            <clientCertificate>
        <authentication certificateValidationMode="PeerOrChainTrust" trustedStoreLocation="LocalMachine" />
        </clientCertificate>
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
<services>
      <service name="HOL.Core.Service.HOLService" behaviorConfiguration="HOLServiceBehaviour">
        <endpoint address="bh" bindingConfiguration="HOLBinding" binding="basicHttpBinding" contract="HOL.Core.Service.IHOLService" />
        <endpoint address="wb" behaviorConfiguration="WebBehaviour" binding="webHttpBinding" contract="HOL.Core.Service.IHOLService" />
      </service>
    </services>

相关客户端服务配置:

<system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="HOLServiceEndpointBehaviour">
          <clientCredentials>
            <clientCertificate storeLocation="LocalMachine" 
                   findValue="mythumbprint" 
                               x509FindType="FindByThumbprint" storeName="TrustedPeople" />

            <serviceCertificate>
               <authentication certificateValidationMode="PeerOrChainTrust"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IHOLService" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000">
            <security mode="Transport">
        <transport clientCredentialType="Certificate" />
         </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://www.myhttpsite.co.uk/Service/HOLService.svc/bh" binding="basicHttpBinding" 
                bindingConfiguration="BasicHttpBinding_IHOLService" contract="HOLCoreService.IHOLService" 
                name="BasicHttpBinding_IHOLService" behaviorConfiguration="HOLServiceEndpointBehaviour">
    </endpoint>
    </client>
  </system.serviceModel>

我的证书正在被发现,所以这不是问题(我也花了一天时间来解决这个问题!)

我认为错误在于调用 WCF 服务的客户端根本没有发送正确的详细信息进行身份验证......但是为什么呢?

4

0 回答 0