Selfhosting a WCF service over Https

浪尽此生 提交于 2019-12-11 15:06:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!