WCF 4 Web 服务中的 UsernameToken 和 SSL

发布于 2024-12-26 04:24:25 字数 542 浏览 2 评论 0原文

我正在创建一个 Web 服务,该服务将由世界另一个地方的单个客户端使用。我对他们正在使用的技术没有任何了解或控制,但我被要求这样做

“在传输过程中使用SSL加密消息并使用UsernameToken 用于客户端身份验证”

我计划使用 WCF4 来创建服务,并且通常知道如何设置这一切。但是我正在努力寻找绑定等的正确配置。Google 给了我很多关于 WSE 3.0 的结果,但我我非常确定(如果我错了,请纠正我)我不应该将 WSE 用于 WCF 服务

。 href="http://msdn.microsoft.com/en-us/library/ms732008.aspx" rel="nofollow">这篇文章最初似乎建议我应该使用自定义绑定,但随后也说我应该“考虑使用具有适当安全设置的 WCF 系统定义的绑定,而不是创建自定义绑定”。但是,

如果有人能指出正确的方向,我将不胜感激 。 。

tl;dr:支持 SSL 和 UsernameToken 的 WCF4 配置设置是什么?

I am creating a web service that will be consumed by a single client in another part of the world. I don't have any knowledge or control over the technology they are using but have been asked to

"use SSL to encrypt the message during transport and use UsernameToken
for client authentication"

I'm planning to use WCF4 to create the service and know generally how to set this all up. However I'm struggling to find the correct configuration for bindings etc. Google gives me lots of results around WSE 3.0 but I'm pretty sure (please correct me if I'm wrong) that I shouldn't be using WSE for a WCF service.

This article initially seems to suggest I should be using a custom binding but then also says I should "consider using the WCF system-defined bindings with appropriate security settings instead of creating a custom binding". However I can't see any examples of what this should be.

I would be grateful if anyone can point me in the right direction.

tl;dr: What are the WCF4 config settings to support SSL and UsernameToken?

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

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

发布评论

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

评论(1

拿命拼未来 2025-01-02 04:24:25

看一下 WsHttpBinding。您可以使用 TransportWithMessageCredential 的安全模式来使用 SSL 和 UserName 的消息凭证。如果您在 IIS 中托管,请在那里设置 SSL。

您可以按如下方式在配置中设置绑定。

<bindings>
  <wsHttpBinding>
    <binding name="secureBinding">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

然后,您可以按如下方式使用此绑定配置。

<services>
  <service name="ServiceName">
    <endpoint address="" binding="wsHttpBinding" contract="ContractType" bindingConfiguration="secureBinding" />
  </service>
</services>

这两个元素都是配置中 system.serviceModel 元素的子元素。

Take a look at the WsHttpBinding. You can use a security mode of TransportWithMessageCredential to use SSL and a message credential of UserName. If you are hosting in IIS set up SSL there.

You can set up the binding in config as follows.

<bindings>
  <wsHttpBinding>
    <binding name="secureBinding">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

You can then use this binding config as follows

<services>
  <service name="ServiceName">
    <endpoint address="" binding="wsHttpBinding" contract="ContractType" bindingConfiguration="secureBinding" />
  </service>
</services>

Both these elements are children of the system.serviceModel element in config.

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