问题标签 [http-signature]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
452 浏览

node.js - In HTTP Signatures, should I use 'request-line' or 'target-request'?

I'm looking at the Readme.md for http-signing that is part of Joyent's node-http-signature module, and it says to use a "special name" to include the HTTP request target into the signature base:

To include the HTTP request line in the signature calculation, use the special request-line value. While this is overloading the definition of headers in HTTP linguism, the request-line is defined in RFC 2616, and as the outlier from headers in useful signature calculation, it is deemed simpler to simply use request-line than to add a separate parameter for it.

Including request-line would imply including text like POST /url/path/here HTTP/1.1 into the signature base.

Conversely draft 03 of the spec says to use a different "special value" to include the request target:

If the header field name is (request-target) then generate the header field value by concatenating the lowercased :method, an ASCII space, and the :path pseudo-headers

Yes, (request-target) in parens.


With the former, the signature base for a request might look like:

...whereas with the latter, the signature base for the same request would look like this:

So which is authoritative? I doubt that there will remain two ways to include the method and path into the signature base.

I suspect "implementations rule", but I'd like to know the real intention.

0 投票
1 回答
408 浏览

node.js - Nodejs - superagent-http-signature - 未发送签名

我正在使用这个网站

节点版本:v4.2.1

如果我检查服务器上的签名标头(顺便运行 PHP,使用自己的签名验证器,使用相同的规范),则缺少签名标头。

有什么我想念的吗?或者是否有任何具有相同功能的替代节点包?

我这样做的目的是能够使用 PHP 之外的其他语言调用 API 作为概念证明,以便我以后可以将其用于 AWS Lambda 计划任务。

0 投票
2 回答
750 浏览

python - 将 Nodejs 签名哈希函数转换为 Python

我正在尝试连接到只有 Nodejs 文档的 API,但我需要使用 Python。

官方文档指出 hhtp 请求需要像这样签名,并且只给出以下代码:

到目前为止,我被阻止在那里:

本质上,我不能让他们的代码在 Nodejs 上运行;我不知道,并且由于私钥格式而出错。所以我无法真正比​​较我所做的事情。然而,我收到一条与 python 相关的禁止消息。

任何想法?

-------------------------------------------------- --------------------

编辑 1

两天后,我是这样的: 1/ 我设法使用 Nodejs 生成了一个有效的签名:

2/ 无法在 Python 中重现 .... 更糟糕的是,无论我尝试什么,哈希值始终是 Nodejs 中哈希值的一半:

这太令人沮丧了,还有什么想法吗?

0 投票
1 回答
202 浏览

node.js - 是否可以将 request-promise 与 httpSignature 一起使用

根据文档,这似乎是可行的。

请求承诺文档

由于 request-promise 包装了 request,所有适用于 request 的东西也适用于 request-promise。另请查看请求文档以获取更多示例。

请求文档说

httpSignature - 使用 Joyent 库的 HTTP 签名方案的选项。必须指定 keyId 和 key 属性。有关其他选项,请参阅文档。

我已经尝试httpSignature: {key, keyId}在我的请求选项中添加一个参数,并且它可以工作,除了它将私钥与请求一起发送,这是不对的。

0 投票
3 回答
804 浏览

rest - 基于 REST 的基于 HTTP 签名的 Web 服务安全性

我一直在研究为我们的 REST Web 服务使用正确的安全机制。我正在阅读有关 HTTP 签名的文档 -> https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12

根据此文档,选择、散列和数字签名的一些 HTTP 标头。此签名字符串在 HTTP 标头中更新。服务提供者将重新创建散列(基于接收到的 HTTP 标头)并验证签名字符串以验证客户端。这也反过来证明消息没有被篡改。

某些有权访问网络的黑客是否有可能只更改 HTTP 正文而不更改作为签名一部分的标头属性。如果是,那么服务提供商收到的消息不是客户端想要的消息,不是吗?那么,这种对 HTTP 请求进行签名的方式如何保证消息的完整性呢?

0 投票
0 回答
29 浏览

java - 如何使用先前创建的密钥和秘密创建签名以访问 rest-api

目前,我正在开发一个只有访问密钥和密钥可用的 API。要访问他们的 API,我需要在 algorithm="hmac-sha256.

他们有一些python代码作为例子

但我正在尝试使用 java 访问它,但没有得到任何好的库或建议来做同样的事情。

如果有人帮助我或建议我任何解决方案,那将非常有帮助..

0 投票
0 回答
74 浏览

c# - 从 .p12 文件创建数字签名以签署 http 请求 C#

我的任务是通过从标准 .p12 文件中检索详细信息来签署 Http 请求。我已经通过执行以下操作来检索 .p12 文件的哈希密码:

现在我有了证书对象,我需要构建一个 HTTP 签名来签署 http 请求。给出的一个示例是 http 签名应如下所示:

我的问题是如何根据我现在拥有的证书中给出的样本构建签名,以及如何将其包含在对资源的请求中?我知道这些细节需要通过标头与请求一起传递,我只需要查看一个如何将其组合在一起的示例。 Keyid = ?? algorithm = "rsa-sha512", headers = "(request-target) host date digest" signature = ????

0 投票
0 回答
46 浏览

swift - 在 Swift 中为 HTTP 签名创建 HMAC SHA256 哈希

我对 Swift 相当陌生,目前正在研究 HTTP 签名。我正在使用this answer中的方法,但该实现不起作用,并且给我的哈希值与我在 Python 中的替代实现中得到的哈希值不同(我更熟悉,但只有密码学原理的基本知识) .

这是斯威夫特代码:

- 编辑 -

在下面@sulthan 的评论之后,将签名的最终格式更改为:

这一切都遵循上述链接的答案。但是具有此签名的 API 调用不起作用,并且看起来不像 Python 实现中的哈希。

Python 中的另一种方法确实有效:

这行得通,不出所料,签名哈希是不同的!如何在 Swift 中模仿这种方法?还是有其他东西,比如标题的顺序,这两者之间可能会有所不同?

两种语言中设置request对象的结构几乎相同:使用目标 URL 创建请求对象,添加所需的非签名标头,然后创建签名并将其添加为最后一个标头。