WCF 传输与消息

发布于 2024-11-01 03:16:42 字数 210 浏览 2 评论 0原文

我正在阅读有关 WCF 安全实现的内容,发现有两种类型的安全性:

传输模式和消息模式(或两者)

如果我使用 HTTPS 作为传输模式,如果我也使用消息安全性是否会更安全?我问这个是因为我的理解如下:

HTTPS 使用 SSL 协议来加密消息。

那么为什么要添加 Message Security 并对 SSL 加密消息进行加密呢?或者我误解了东西?

I was reading about WCF security implementations and found out that there are 2 types of security:

Transport Mode and Message Mode (or both)

If I used HTTPS for Transport Mode, is it more secured if I used Message security also? I am asking this because what I understand is as follows:

HTTPS uses SSL protocol which encrypts messages.

So why should I add Message Security and encrypt the SSL encrypted message? Or am I misunderstanding stuff?

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

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

发布评论

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

评论(4

夜还是长夜 2024-11-08 03:16:42

WCF 中的安全性实际上 由几个功能组成。两者之间的区别在于消息的签名和加密方式。

传输安全仅提供点对点的通道安全。这意味着HTTPS仅在客户端和暴露给客户端的服务器之间建立安全通道。但是,如果该服务器只是负载均衡器或反向代理服务器,则它可以直接访问消息的内容。

消息安全提供端到端的通道安全。这意味着安全性是传输数据的一部分,只有预期的目的地才能解密数据(负载均衡器或代理只能看到加密的消息)。在大多数情况下,消息安全性也使用证书来提供加密和签名,但通常速度较慢,因为传输安全性可以使用硬件加速。

在高级场景中,可以组合这些方法。例如,您可以通过 HTTPS 保护与负载均衡器的通信,因为您信任负载均衡器之后的内部网络,但同时您可以对消息进行签名(消息安全),以便您可以证明它没有被更改。

两者之间的另一个区别是传输安全性与单一传输协议相关,而消息安全性独立于传输协议。

消息安全性基于可互操作的协议(但请注意,并非 WCF 中的每个配置都是可互操作的)。 WCF 至少部分支持以下协议:

  • WS-Security 1.0 和 1.1 - 加密、签名、令牌传输、时间戳等的基本规则。
  • UserName 令牌配置文件 1.0 - 用于传输用户名和密码的令牌的定义。此规范仅部分实现,因为 WCF 开箱即用不支持摘要式密码,并且需要将此令牌与传输或消息加密结合使用。
  • X509 令牌配置文件 1.1 - 用于传输证书的令牌的定义。
  • Kerberos 令牌配置文件 1.1 - 用于传输 Kerberos 票证的令牌的定义。
  • SAML 1.1 令牌配置文件 1.0 和 1.1 - 用于联合安全性的令牌的定义。 SAML 2.0 由 WIF 提供。
  • WS-SecurityPolicy 1.1 和 1.2 - 提供对在 WSDL 中定义安全断言的支持。
  • WS-SecureConversation 1.3 和 2005 年 2 月 - 提供对安全会话的支持,其中仅在第一次调用期间交换凭证,其余通信使用唯一的安全令牌。
  • WS-Trust 1.3 和 2005 年 2 月 - 提供对联合场景和安全令牌服务 (STS) 的支持。

WCF 还支持 WS-I 基本安全配置文件 1.0,它只是具有规定配置的以前协议的子集。

对于不可互操作的功能,WCF 提供了 Windows 安全性或 TLSNego 和 SPNego 等功能(两者通常应该是可互操作的,但它们在许多 SOAP 堆栈中不可用)用于服务凭据交换。

Security in WCF actually consists of several features. The difference between those two is how are messages signed and encrypted.

Transport security provides only point-to-point channel security. It means that HTTPS establish secure channel only between client and server exposed to client. But if this server is just a load balancer or reverse proxy server it has direct access to content of the message.

Message security provides end-to-end channel security. It means that security is part of transferred data and only intended destination can decrypt the data (load balancer or proxy sees only encrypted message). Message security in most cases also uses certificates to provide encryption and signing but it is usually slower because transport security can use HW acceleration.

In advanced scenarios these methods can be combined. For example you can have communication to your load balancer secured by HTTPS because you trust your internal network after load balancer but in the same time you can have the message signed (message security) so you can prove that it wasn't changed.

Another difference between those two is that transport security is related to single transport protocol whereas message security is independent on transport protocol.

Message security is based on interoperable protocols (but be aware that not every configuration in WCF is interoperable). WCF supports at least partially these protocols:

  • WS-Security 1.0 and 1.1 - basic rules for encryption, signing, token transport, timestamps, etc.
  • UserName token profile 1.0 - definition of token used for transporting user name and password. This specification is implemented only partially because WCF out of the box doesn't support digested password and requires using this token either with transport or message encryption.
  • X509 token profile 1.1 - definition of token used for transporting certificates.
  • Kerberos token profile 1.1 - definition of token used for transporting Kerberos tickets.
  • SAML 1.1 token profile 1.0 and 1.1 - definition of token used for federated security. SAML 2.0 is provided by WIF.
  • WS-SecurityPolicy 1.1 and 1.2 - provides support for defining security assertion in WSDL.
  • WS-SecureConversation 1.3 and Feb. 2005 - provides support for security session where credentials are exchanged only during first call and rest of the communication uses unique security token.
  • WS-Trust 1.3 and Feb. 2005 - provides support for federated scenarios and Security token services (STS).

WCF also supports WS-I Basic Security Profile 1.0 which is just subset of former protocols with prescribed configuration.

For non interoperable features WCF offers features like Windows security or TLSNego and SPNego (both should be generally interoperable but their are not available in many SOAP stacks) for service credentials exchange.

春花秋月 2024-11-08 03:16:42

链接概述了使用或不使用邮件安全性的原因。

基本上,除非无法使用,否则传输安全是首选。

链接摘录:

传输级的优缺点
安全性

运输安全有以下内容
优点:

不要求
沟通双方理解
XML 级安全概念。这个可以
提高互操作性,对于
例如,当使用 HTTPS 来保证安全时
沟通。

性能普遍提高。

硬件加速器可用。

可以进行流式传输。

运输安全有以下内容
缺点:

仅限逐跳。

有限且不可扩展的集合
证书。

依赖于运输。

消息级别的缺点
安全性

消息安全具有以下特点
缺点:

性能

无法使用消息流。

需要实现 XML 级别
安全机制和支持
WS-安全规范。这可能
影响互操作性。

This link outlines the reasons to use or not to use Message security.

Basically, transport security is preferred unless it cannot be used.

An excerpt fro the link:

Pros and Cons of Transport-Level
Security

Transport security has the following
advantages:

Does not require that the
communicating parties understand
XML-level security concepts. This can
improve the interoperability, for
example, when HTTPS is used to secure
the communication.

Generally improved performance.

Hardware accelerators are available.

Streaming is possible.

Transport security has the following
disadvantages:

Hop-to-hop only.

Limited and inextensible set of
credentials.

Transport-dependent.

Disadvantages of Message-Level
Security

Message security has the following
disadvantages:

Performance

Cannot use message streaming.

Requires implementation of XML-level
security mechanisms and support for
WS-Security specification. This might
affect the interoperability.

世俗缘 2024-11-08 03:16:42

在某些情况下,您可能无法进行传输级加密,因此“回退”到消息级加密,这只是比传输级安全性稍差一些。

当然,两者都做会更安全。但当您拥有良好的传输级别安全性时,这有点矫枉过正。

There are also cases where you might not be able to have transport level encryption and thus 'fall back' to message level encryption, which is just a little bit less secure then transport level security.

Doing both will be more secure, sure. But it is a bit of overkill when you have good transport level security.

套路撩心 2024-11-08 03:16:42

我想说,在大多数情况下,其中之一就足够了。如果您可以使用传输级安全性,那么这是更好的选择,因为它会加密整个通信,而不仅仅是消息内容。

I would say that it in most cases should suffice with one or the other. If you can use transport level security that is preferable since it encrypts the entire communication, not only the message content.

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