简体   繁体   English

从 Node.JS 向 DocuSign 发送请求时强制设置 TLS vresion 1.2

[英]Force setting TLS vresion 1.2 when sending out a request from Node.JS to DocuSign

We are having difficulty sending a request through a corporate proxy from our Node.JS application to DocuSign (demo.docusign.net and account-d.docusign.com)/ We've identified that the issue is possibly due to the DocuSign server accepting TLS 1.1 and 1.2 only.我们在通过公司代理从我们的 Node.JS 应用程序向 DocuSign(demo.docusign.net 和 account-d.docusign.com)发送请求时遇到困难/我们已经确定问题可能是由于 DocuSign 服务器接受仅限 TLS 1.1 和 1.2。

Is there any way to force set the TLS version to TLS 1.2 for requests?有什么方法可以强制将请求的 TLS 版本设置为 TLS 1.2? If there are any request modules (axios, got, request) that supports this and if there are code examples it would be very helpful.如果有任何支持此功能的请求模块(axios、got、request)并且如果有代码示例,那将非常有帮助。

Thanks alot in advance!提前非常感谢!

You can specify the min and max TLS version to use by setting tls.DEFAULT_MAX_VERSION and tls.DEFAULT_MIN_VERSION.您可以通过设置 tls.DEFAULT_MAX_VERSION 和 tls.DEFAULT_MIN_VERSION 来指定要使用的最小和最大 TLS 版本。

This should then apply to any module that uses the core Node.js TLS code.这应该适用于使用核心 Node.js TLS 代码的任何模块。

For example:例如:

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();

Here we connect to an https server and log the TLS version of the connection.在这里,我们连接到 https 服务器并记录连接的 TLS 版本。 You can play about with the MIN and MAX TLS versions to see how it affects the protocol used.您可以使用 MIN 和 MAX TLS 版本来查看它如何影响所使用的协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM