http - 是否可以使用 TLS 验证 http 请求的发件人来源
问题描述
我创建了一个 API 端点,我有该端点的用户从stackoverflow.com
. 我想验证请求是从stackoverflow.com
服务器发出的。我可以验证它来自的一种方法stackoverflow.com
是要求开发人员使用他们的让我们加密域私钥签署请求。然后我可以使用他们的公钥来解密消息。
我不完全确定我可以用他们的公钥解密私人加密的消息,但即使我可以,我想避免让开发人员进行任何特殊类型的加密。我可以使用 TLS 来验证源域吗?
解决方案
TLS 支持客户端身份验证,也称为“双向”或“双向”身份验证。(SSL3 也有,但您不应该使用 SSL3。)参见例如TLS1.2 'updated' 的ECC和TLS1.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).
推荐阅读
- c# - 在 Xamarin Android 中询问权限 CaptureAudioOutput 的问题
- c# - Unity 2d某种输入滞后,还是别的什么?
- serialization - 如何将具有 C++ 样式的十六进制浮点数 (%a) 的字符串解析为 f64?
- assembly - 加载字/存储字中的字节序混淆 (MIPS/QtSpim)
- docker - docker-compose 运行命令:无法成功运行 Windows 10
- r - 如何将某些二进制 V. 的特定值分配为 glm 中的预测变量?
- android - 如何在双簧管播放的同时录制音频
- ansible-awx - 如何在 azure kubernetes 服务中安装 Ansible AWX?
- linux - mininet 中的多个会话
- php - Composer 安装“PHP 警告:PHP 启动:无法加载动态库 'gd2'”