I'm trying to configure a WCF REST service to be accessible using HTTP as well as using HTTPS.
Since this is an in production service I would like to minimize the changes required to get HTTPS up and running. I would like to achieve a solution in which the admin only needs to replace the http:// with https://. According to this Wcf HTTP and HTTPS on the same host/port it should be possible to achieve this but I'm struggling with the configuration.
<services>
<service name="My.Server">
<!-- HTTP services -->
<endpoint address="/Common/"
behaviorConfiguration="restEndpointBehavior"
binding="webHttpBinding"
contract="My.IServer" />
<!-- HTTPS services -->
<endpoint address="/Common/"
behaviorConfiguration="restEndpointBehavior"
binding="webHttpBinding"
bindingConfiguration="httpsBindingConfiguration"
contract="My.IServer" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/MyService" />
<add baseAddress="https://localhost:8732/MyService" />
</baseAddresses>
</host>
</service>
</services>
Everything works fine as long as I'm just using either the HTTP or the HTTPS binding (tested using Postman) but as soon as I activate both endpoints the service startup fails stating:
Service cannot be started. System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL https://+:8732/MyService/Common/. Another application has already registered this URL with HTTP.SYS. ---> System.Net.HttpListenerException: Failed to listen on prefix 'https://+:8732/MyService/Common/' because it conflicts with an existing registration on the machine.
I'm aware of all the netsh http urlacl|sslcert stuff and can confirm that those should not be an issue since using only one endpoint (either HTTP or HTTPS) or changing the port for HTTPS e.g. :8733 fixes the issue and the service reponds as expected but as stated earlier I would like to use the same ports.
After researching and trying for quite some time now my guess is that such a configuration is not supported. Can anybody confirm my guess or does know a way to achieve the desired result?