@arnoldo.moen
To setup a WCF service to run on HTTPS, follow these steps:
Example configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<bindings> <basicHttpBinding> <binding name="SecureBinding"> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </basicHttpBinding> </bindings> <services> <service name="YourServiceName"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SecureBinding" contract="YourContractName" /> </service> </services> |
Example self-hosting code:
1 2 3 4 5 6 7 8 9 10 11 12 |
Uri baseAddress = new Uri("https://localhost:8000/YourServiceName"); ServiceHost host = new ServiceHost(typeof(YourService), baseAddress); host.Credentials.ServiceCertificate.SetCertificate( StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "YourCertificateSubjectName"); host.AddServiceEndpoint(typeof(IYourContract), new BasicHttpBinding(), baseAddress); host.Open(); |
By following these steps, you can successfully set up a WCF service to run on HTTPS and secure the communication between clients and the service.