2010-11-02 62 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端點。這應該得到它的工作