gpt4 book ai didi

javascript - 从 Node.JS 向 DocuSign 发送请求时强制设置 TLS 版本 1.2

转载 作者:行者123 更新时间:2023-12-02 02:42:46 25 4
gpt4 key购买 nike

我们在通过公司代理从 Node.JS 应用程序向 DocuSign(demo.docusign.net 和 account-d.docusign.com)发送请求时遇到困难/我们已确定该问题可能是由于DocuSign 服务器仅接受 TLS 1.1 和 1.2。

有没有办法强制将请求的 TLS 版本设置为 TLS 1.2?如果有任何请求模块(axios、got、request)支持此功能,并且有代码示例,那将非常有帮助。

提前非常感谢!

最佳答案

您可以通过设置 tls.DEFAULT_MAX_VERSION 和 tls.DEFAULT_MIN_VERSION 来指定要使用的最小和最大 TLS 版本。

这应该适用于使用核心 Node.js TLS 代码的任何模块。

例如:

const axios = require("axios");
const tls = require("tls");

tls.DEFAULT_MIN_VERSION = "TLSv1.1";
tls.DEFAULT_MAX_VERSION = "TLSv1.3";

async function testTLSVersion() {
let response = await axios({ url: "https://httpbin.org/get"});
console.log("TLS Version of connection:", response.request.connection.getProtocol());
}

testTLSVersion();

这里我们连接到 https 服务器并记录连接的 TLS 版本。您可以尝试使用 MIN 和 MAX TLS 版本,看看它如何影响所使用的协议(protocol)。

关于javascript - 从 Node.JS 向 DocuSign 发送请求时强制设置 TLS 版本 1.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63296828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com