SSL上的REST WCF服务

Pet*_*ter 5 rest ssl wcf

我试图通过SSL配置REST WCF服务,我一直在:

找不到与绑定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>
Run Code Online (Sandbox Code Playgroud)

Lad*_*nka 5

让我猜一下:您正在开发Web服务器(Cassini)中从Visual Studio运行您的服务,不是吗?开发Web服务器不支持HTTPS.您必须在IIS中托管您的服务,并遵循Greg的建议为该站点添加HTTPS绑定.


Gre*_*som 3

您需要在 IIS 中添加 https 绑定。

  1. 在 IIS 中导航到您的站点
  2. 单击右侧“操作”面板中的“绑定...”。
  3. 点击“添加”
  4. 选择“https”并选择一个证书。