问题
I want to write a WCF service (self-hosted) that should use https. By searching the web I found a blog article from msdn that tells me to use the "netsh.exe" command to bind the certificate to the endpoint by commandline: http://blogs.msdn.com/b/james_osbornes_blog/archive/2010/12/10/selfhosting-a-wcf-service-over-https.aspx
However, is this still state of the art? Why not use this: http://msdn.microsoft.com/de-de/library/system.servicemodel.description.servicecredentials.servicecertificate(v=vs.100).aspx
Or do I miss something? Thanks for any help.
回答1:
So I finally found out why I need to use the netsh command:
Check this article: https://msdn.microsoft.com/en-us/library/ms789011%28v=vs.110%29.aspx
From this article: If the transport is HTTP (using the WSHttpBinding), SSL over HTTP provides the transport-level security. In that case, you must configure the computer hosting the service with an SSL certificate bound to a port, as shown later in this topic. If the transport is TCP (using the NetTcpBinding), by default the transport-level security provided is Windows security, or SSL over TCP. When using SSL over TCP, you must specify the certificate using the SetCertificate method, as shown later in this topic.
So you can only use the Property for tcp binding. If you use ssl over http, you need to bind a certificate to a port by netsh command
来源:https://stackoverflow.com/questions/24158884/selfhosting-a-wcf-service-over-https