8

这似乎是一个常见问题,我已经查看了这里的所有答案,但没有任何帮助。

我试图让 SSL 与托管在 iis 上的 basichttpbinding 和 WCF 服务一起使用。我认为问题出在 iis 或证书上。我在 iis 管理器中创建了一个自签名证书。我的证书被称为“mycomputer”,并且也被置于受信任的根证书之下。客户端找到证书没有问题。

我在 iis 中的设置是启用匿名身份验证,并禁用其他所有功能。还需要 SSL 并接受客户端证书。那是对的吗?如果我选择忽略,我会收到错误消息。

我看不出我的配置有什么问题,这些正确吗?

服务配置:

<system.serviceModel>
<services> 
  <service behaviorConfiguration="MyBehaviour" name="BasicHttpSecTest.Service1"> 
    <endpoint name="MyEndPoint" address="https://mycomputer/wp/" binding="basicHttpBinding" bindingConfiguration="ClientCertificateTransportSecurity" contract="BasicHttpSecTest.IService1" /> 
    <!--<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />-->
  </service> 
</services> 
<behaviors> 
  <serviceBehaviors> 
    <behavior name="MyBehaviour"> 
      <serviceMetadata httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/>
        </clientCertificate>
      </serviceCredentials>
    </behavior> 
  </serviceBehaviors> 
</behaviors> 
<bindings> 
  <basicHttpBinding> 
    <binding name="ClientCertificateTransportSecurity"> 
      <security mode="Transport"> 
        <transport clientCredentialType="Certificate" />
      </security> 
    </binding> 
  </basicHttpBinding> 
</bindings>
</system.serviceModel> 

客户端配置:

<system.serviceModel> 
<client>
    <endpoint address="https://mycomputer/wp/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="MyEndPoint" contract="ServiceSSLref.IService1"
        name="MyEndPoint1" behaviorConfiguration="ClientCertificateCredential"/>
</client>

<bindings>
    <basicHttpBinding>
        <binding name="MyEndPoint">
            <security mode="Transport">
                <transport clientCredentialType="Certificate" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>

<behaviors> 
  <endpointBehaviors> 
    <behavior name="ClientCertificateCredential"> 
      <clientCredentials> 
        <clientCertificate findValue="mycomputer" storeLocation="LocalMachine" storeName="My" x509FindType="FindByIssuerName" />
        <serviceCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/>
        </serviceCertificate>
      </clientCredentials> 
    </behavior> 
  </endpointBehaviors> 
</behaviors>
</system.serviceModel>
4

1 回答 1

6

我想您的问题可能出在您的客户端证书中。设置 clientCredentialType="Certificate" 您告诉 WCF,客户端必须指定服务器信任的证书。据我了解,您只有服务器端生成的证书。尝试设置

 <transport clientCredentialType="None" /> 

这将允许您在不需要服务器信任的证书的情况下发送消息。或者您可以尝试在客户端生成证书并将其放入服务器上的 Trusted 文件夹中。也许这种状态会帮助你http://msdn.microsoft.com/en-us/library/ms731074.aspx

于 2013-02-13T12:42:07.637 回答