Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST WCF Service Over SSL

Tags:

rest

ssl

wcf

I am trying to configure a REST WCF service over SSL and I keep getting:

Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http].

Can somebody please take a look at my config file? Thanks.

  <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>
like image 549
Peter Avatar asked Jan 10 '11 20:01

Peter


People also ask

What is protocol mapping in WCF?

<protocolMapping> Represents a configuration section for defining a set of default protocol mapping between transport protocol schemes (e.g., http, net. tcp, net. pipe, etc.) and WCF bindings.

What is WCF REST API?

WCF (Windows Communication Foundation) is a secure, reliable, and scalable messaging platform that can be used to build Web services in . Net. It provides a unified programming model for developing service oriented applications. You can use WCF to build RESTful services in . NET.


1 Answers

Let me guess: You are running your service from Visual Studio in Developement web server (Cassini), don't you? Development web server does not support HTTPS. You have to host your service in IIS and follow Greg's advice to add HTTPS binding for the site.

like image 185
Ladislav Mrnka Avatar answered Sep 24 '22 03:09

Ladislav Mrnka