2010-11-02 63 views
0

,当我访问我的web服务本地主机/为MyService我收到以下错误/ MyService.svc交通运输安全与证书认证

为服务“SslRequireCert”不匹配的IIS“的SSL设置Ssl,SslNegotiateCert'。

http://msdn.microsoft.com/en-us/library/ms731074.aspx

这里指定我下面的Web.config例子是我的WCF服务器的web.config:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 
    <appSettings /> 
    <system.web> 
    <identity impersonate="false" /> 
    <roleManager enabled="true" /> 
    <authentication mode="Windows" /> 
    <customErrors mode="Off" /> 
    <webServices> 
     <protocols> 
     <add name="HttpGet" /> 
     <add name="HttpPost" /> 
     </protocols> 
    </webServices> 
    </system.web> 
    <system.webServer> 
    <directoryBrowse enabled="true" /> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <security> 
     <authorization> 
     <remove users="*" roles="" verbs="" /> 
     <add accessType="Allow" users="*" roles="" /> 
     </authorization> 
    </security> 
    </system.webServer> 
    <system.serviceModel> 
    <services> 
     <service name="AspNetSqlProviderService" behaviorConfiguration="MyServiceBehavior"> 
     <endpoint binding="wsHttpBinding" contract="Interface1" bindingConfiguration="CertificateWithTransportWSHttpBinding" /> 
     <endpoint binding="wsHttpBinding" contract="Interface2" bindingConfiguration="CertificateWithTransportWSHttpBinding" /> 
     <endpoint address="mex" binding="wsHttpBinding" bindingConfiguration="CertificateWithTransportWSHttpBinding" name="Metadata_Exchange" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyServiceBehavior"> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
      <serviceMetadata /> 
      <serviceCredentials> 
      <clientCertificate> 
       <authentication trustedStoreLocation="LocalMachine" 
           revocationMode="Online"/> 
      </clientCertificate> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="CertificateWithTransportWSHttpBinding"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Certificate" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

我已经配置了IIS如下:

  • 使用自签名证书添加https绑定
  • 根据S SL设置,需要SSL并接受客户端证书
  • 自签名证书已添加到本地计算机受信任的根CA.

我可以浏览和执行.asmx服务定义,但.svc给了我上面描述的错误。

回答

0

具体的过程

  1. 创造自我在IIS签名证书。
  2. 在IIS中创建网站。
  3. 将网站设置为需要SSL。
  4. 当您在绑定中选择https协议时,IIS 7中的小故障将不允许您指定站点的主机名。有指示here正确设置此绑定的主机名。
  5. 在你的web配置修改它像这样

    <wsHttpBinding> 
        <binding name="CertificateWithTransportWSHttpBinding"> 
         <security mode="Transport"> 
          <transport clientCredentialType="none" /> 
         </security> 
        </binding> 
    </wsHttpBinding> 
    
    
    <serviceBehaviors> 
        <behavior name="MyServiceBehavior"> 
         <serviceDebug includeExceptionDetailInFaults="True" /> 
         <serviceMetadata /> 
        </behavior> 
    </serviceBehaviors> 
    
  6. 在您的MEX端点设置绑定=“wsHttpsBinding”

如果你做了这一切之上,你应该起来使用SSL WCF服务运行。

1

试着注释掉你的mex端点。这应该得到它的工作