当我不希望使用传输的 WCF 时,它总是尝试使用 HTTPS
我不断收到以下错误“无法找到与绑定 WebHttpBinding 的端点的方案 https 相匹配的基地址。注册的基地址方案是 [http]。”这是因为我通过添加以下内容进入基本传输身份验证:
<webHttpBinding>
<binding name="secureBasic">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>
在谷歌搜索后,常见的修复似乎是以下代码,但我没有成功:
<baseAddressPrefixFilters>
<add prefix="http://mywebsiteurl"/>
</baseAddressPrefixFilters>
仍然没有任何效果。我想要的只是在非 https 连接上使用基本的 http 身份验证。我完全没有配置任何内容,默认情况下 WCF 似乎想要强制 HTTPS 连接。有人遇到过这个吗?
I keep getting the following error "Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http]." This started because I went to Basic Transport Authentication by adding:
<webHttpBinding>
<binding name="secureBasic">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>
After googling the common fix seemed to be the following code, but I had no success with it:
<baseAddressPrefixFilters>
<add prefix="http://mywebsiteurl"/>
</baseAddressPrefixFilters>
Still, nothing works. All I want is to use basic http authentication on a non-https connection. I have configured absolutely nothing and it appears by default WCF wants to force a HTTPS connetion. Anyone run into this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果告诉 WCF 使用传输安全模式,则必须使用支持安全通信的传输协议。 HTTP 不支持安全通信,因为它是纯文本协议(拦截您的通信的任何人都可以简单地读取正在传输的内容)。 HTTPS 确实支持安全通信,因此具有传输安全性的
webHttpBinding
的唯一选择是使用 HTTPS(可以在 IIS 中配置)。这里是一篇博客文章,描述了您的错误以及如何解决使用TransportCredentialOnly来解决它。这是关于 basicHttpBinding 的,但同样适用于您的 webHttpBinding。
If you tell WCF to use transport security mode, you must use a transport protocol that supports secure communication. HTTP doesn't support secure communication because it's a plaintext protocol (anyone that intercepts your communication can simply read what is being transmitted). HTTPS does support secure communication so your only option for a
webHttpBinding
with transport security is to use HTTPS (which you can configure in IIS).Here is a blog post describing your error and how to solve it using
TransportCredentialOnly
. It's aboutbasicHttpBinding
but the same holds for yourwebHttpBinding
.如果您只需要传输级别身份验证(= 基本身份验证),但不需要传输级别安全通信(= HTTPS),则必须将安全模式设置为 TransportCredentialOnly。
If you want only transport level authentication (= Basic authentication) but you don't want transport level secure communication (= HTTPS) you have to set security mode to TransportCredentialOnly.