首页 > 解决方案 > 是否可以使用 TLS 验证 http 请求的发件人来源

问题描述

我创建了一个 API 端点,我有该端点的用户从stackoverflow.com. 我想验证请求是从stackoverflow.com服务器发出的。我可以验证它来自的一种方法stackoverflow.com是要求开发人员使用他们的让我们加密域私钥签署请求。然后我可以使用他们的公钥来解密消息。

我不完全确定我可以用他们的公钥解密私人加密的消息,但即使我可以,我想避免让开发人员进行任何特殊类型的加密。我可以使用 TLS 来验证源域吗?

标签: httpsecurityhttpscryptographytls1.2

解决方案


TLS 支持客户端身份验证,也称为“双向”或“双向”身份验证。(SSL3 也有,但您不应该使用 SSL3。)参见例如TLS1.2 'updated' 的ECCTLS1.3

如何使用它取决于用于 TLS 的软件(通常是库或中间件),您没有指出;甚至有可能某些 TLS 堆栈根本不支持它,尽管我从未听说过。一些堆栈或用例允许在没有任何代码更改的情况下调用客户端身份验证,而其他堆栈或用例只需要进行最小或本地化的代码更改。

一些可能重要或不重要的细节:

  • 这不签署请求。它验证 TLS连接(准确地说,它通常签署握手记录),然后使用由握手创建(并因此验证)的密钥对通过连接传输的数据进行 MAC 化(以及加密)。这为数据提供了身份验证但不提供不可否认性;接收方可以可靠地确定它来自发送方,但您无法可靠地向第三方证明这一点。对于“证明”服务器的密切相关案例,请参阅链接在https://security.stackexchange.com/questions/205074/is-it-possible-to-save-a-verifiable-log-of-一个-tls-会话

  • this authenticates the data was sent by the identified client; it says nothing about the origin which as Sam Jason points out is often different.

  • the client is not necessarily identified by a domain name; it can be a person, organization, or something else. However, many CAs issue a single cert for both TLS server auth and client auth (look at the ExtendedKeyUsage extension in your own or any sample cert(s) to see) and in that case with few exceptions the subject is identified by a domain name or name(s) or at least wildcard(s).


推荐阅读