2011-01-10 229 views
5

我想配置通過SSL進行REST WCF服務,我不斷收到:REST WCF服務在SSL

無法爲端點 具有約束力的WebHttpBinding找到一個基地址 匹配方案HTTPS。 註冊的基地址方案是 [http]。

有人可以看看我的配置文件嗎?謝謝。

<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="wsHttpBinding1"> 
      <security> 
      <message clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
     <mexHttpsBinding> 
     <binding name="mexHttpsBinding1"/> 
     </mexHttpsBinding> 
     <webHttpBinding> 
     <binding name="webHttpBinding1"> 
      <security mode="Transport" /> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="serviceBehavior" name="CompanyX.WebServices.WebApi"> 
     <endpoint address="" behaviorConfiguration="WebApiBehavior" binding="webHttpBinding" 
      bindingConfiguration="webHttpBinding1" contract="CompanyX.WebServices.IWebApi"> 
      <identity> 
      <certificateReference x509FindType="FindBySubjectName" findValue="CompanyXDev" 
       isChainIncluded="false" storeName="My" storeLocation="LocalMachine" /> 
      </identity> 
     </endpoint> 
     <endpoint binding="mexHttpsBinding" bindingConfiguration="mexHttpsBinding1" 
      name="mex" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="WebApiBehavior"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="serviceBehavior"> 
      <serviceMetadata httpsGetEnabled="true" httpGetBinding="" httpsGetBinding="webHttpBinding" 
      httpsGetBindingConfiguration="webHttpBinding1" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceCredentials> 
      <clientCertificate> 
       <certificate findValue="CompanyXDev" x509FindType="FindBySubjectName" /> 
      </clientCertificate> 
      <serviceCertificate findValue="CompanyXDev" x509FindType="FindBySubjectName" /> 
      <userNameAuthentication userNamePasswordValidationMode="Custom" 
       customUserNamePasswordValidatorType="CompanyX.WebServices.CredentialsValidator, CompanyX.WebServices" /> 
      <peer> 
       <certificate findValue="CompanyXDev" storeLocation="LocalMachine" 
       x509FindType="FindBySubjectName" storeName="My" /> 
      </peer> 
      <issuedTokenAuthentication> 
       <knownCertificates> 
       <add findValue="CompanyXDev" storeLocation="LocalMachine" storeName="My" 
        x509FindType="FindBySubjectName" /> 
       </knownCertificates> 
      </issuedTokenAuthentication> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
     multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 
+5

看起來你有超過配置您的服務主機點點,沒有你? – 2011-01-10 21:56:48

回答

3

您需要添加HTTPS在IIS結合。

  1. 瀏覽到您的網站在IIS
  2. 在動作面板右側點擊「綁定...」。
  3. 點擊'添加'
  4. 選擇'https'並選擇一個證書。
5

讓我猜測:您正在使用開發Web服務器(Cassini)中的Visual Studio運行您的服務,不是嗎?開發Web服務器不支持HTTPS。您必須在IIS中託管您的服務,並按照Greg的建議爲該站點添加HTTPS綁定。

2

兩個選擇:

  1. 指定端點的詳細地址。

  2. 在標籤中指定的地方用於主機的基地址,例如:

<host> 
    <baseAddresses> 
    <add baseAddress="http://localhost:8000/service"/> 
    <add baseAddress="https://localhost:8001/service"/> 
    </baseAddresses> 
</host>