2011-01-10 228 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>