WCF HTTPS 自托管服务不起作用(“与服务器的连接已重置”)

发布于 2024-08-06 12:36:57 字数 817 浏览 5 评论 0原文

我有一个具有以下绑定的自托管(控制台应用程序)WCF REST 服务:

  • WebMessageEncodingBindingElement
  • HttpsTransportBindingElement (ManualAddressing=true, KeepAliveEnabled=true, AllowCookies=false, HostNameComparisonMode=Exact)

这是通过 HTTPS URL 公开的 ("https://mylaptop/myendpoint")

我有一个颁发给“mylaptop”的自签名证书,我使用 myServiceHost.Credentials.ServiceCertificate 分配该证书。设置证书。证书添加成功,ServiceHost打开成功(无异常)。如果我输入“netsh http show servicestate”,我可以看到 https://mylaptop/myendpoint 已成功注册HTTP.SYS

但是,当我向端点发出 GET 时,它不起作用。看起来套接字甚至在获得有效的 HTTP 响应之前就被丢弃了。 (FireFox 说“与服务器的连接已重置”,IE 说“无法显示网页”,如果我通过 Fiddler 发出请求,它会说“连接被远程主机强制关闭”)。

当我使用 HTTP 而不是 HTTPS 时,一切正常。

知道 HTTPS 情况下可能出现什么问题吗?

I have a Self-Hosted (Console App) WCF REST service with the following binding:

  • WebMessageEncodingBindingElement
  • HttpsTransportBindingElement (ManualAddressing=true, KeepAliveEnabled=true, AllowCookies=false, HostNameComparisonMode=Exact)

This is exposed over an HTTPS URL ("https://mylaptop/myendpoint")

I have a self-signed certificate issued to "mylaptop" that I assign using myServiceHost.Credentials.ServiceCertificate.SetCertificate. The certificate is added successfully, and the ServiceHost opens successfully (no exceptions). If I type "netsh http show servicestate", I can see that there's a successful registration at https://mylaptop/myendpoint with HTTP.SYS

However, when I issue a GET to the endpoint, it doesn't work. It seems like the socket is dropped even before a valid HTTP response is obtained. (FireFox says "connection to the server was reset", IE says "cannot display the webpage", and if I do the request through Fiddler it says "connection was forcibly closed by the remote host").

Everything works fine when I use HTTP instead of HTTPS.

Any idea what could be going wrong in the HTTPS case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风尘浪孓 2024-08-13 12:36:57

您可能需要使用 httpcfg.exe 通过配置的 SSL X.509 证书正确保留 HTTP.SYS 的端点。 此处记录了完成此操作的步骤。

You probably need to use httpcfg.exe to reserve your endpoint with HTTP.SYS correctly with a configured X.509 certificate for SSL. The steps to get it done are documented here.

罗罗贝儿 2024-08-13 12:36:57

或者使用 HttpCfgGui - 一个更友好的界面来设置带有 HTTP.SYS 的服务器证书。这是我所有使用 WCF 执行 HTTP 的服务器上必须安装的。

Or use HttpCfgGui- a much friendlier interface to setting up the server certs w/ HTTP.SYS. This is a must-install on all my servers that do HTTP w/ WCF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文