Azure AMS 节点 js 应用无法建立 TLS 1.2 连接
Azure AMS node js app failing to make a TLS 1.2 connection
我有一个节点 js 应用程序 运行 作为 Azure AMS 上的移动服务。我一直在使用请求库对外部服务器进行 HTTPS get/post api 调用。直到几天前,当外部实体决定停止支持 TLS 1.0 及更低版本时,一切都可以正常工作。
我想知道是否有人知道 Azure AMS blocking/failing TLS 1.1/1.2 与外部主机通信的任何已知问题?该主机使用由 DigiCert 颁发的有效 SSL 证书。
在我的代码中,我已经尝试了一些方法来明确告诉 nodejs 使用 TLS 1.1 / 1.2,但这没有用。
var httpRequest = require("request"),
https = require('https');
https.globalAgent.options.secureProtocol = 'TLSv1_2_method'; // Instructing to use TLS 1.2
....
httpRequest.post('https://external-api-url.com', {
'json': true,
'body': params,
'timeout': 20000,
'jar': false,
'headers': {
"Arr-Disable-Session-Affinity": true
}
}, function(err, response, body) {
// Code to handle response.
});
除了 globalAgent,我还尝试从 agentOptions 以及直接从选项对象中设置 secureProtocol。 None 的方法奏效了。
任何帮助将不胜感激。
谢谢。
您的问题是 Azure 移动服务上的 NodeJS 版本问题。
Azure 移动服务上的 NodeJS 版本是 v0.8.28。可以在Azure Kudu Env页面https://<your_ams_name>.scm.azure-mobile.net/Env的"AppSettings"部分看到,如下图
但是,NodeJS从0.11.6版本开始将TLS 1.1/1.2添加到secureProtocol列表中,如下图。
因此,当外部实体决定停止支持 TLS 1.0 时,您的 nodejs 应用无法运行。
但是您可以按照 NodeJS 示例使用 Https APIs 支持 TLS 或请求模块 API 支持 TLS/SSL 协议来设置 options.key & options.cert 去做吧。
请参考https://nodejs.org/docs/v0.8.28/api/https.html#https_https_request_options_callback and https://github.com/request/request#tlsssl-protocol.
示例:
var fs = require('fs')
, path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key')
, request = require('request');
https.globalAgent.options.cert = certFile;
https.globalAgent.options.key = keyFil;
此致。
我有一个节点 js 应用程序 运行 作为 Azure AMS 上的移动服务。我一直在使用请求库对外部服务器进行 HTTPS get/post api 调用。直到几天前,当外部实体决定停止支持 TLS 1.0 及更低版本时,一切都可以正常工作。
我想知道是否有人知道 Azure AMS blocking/failing TLS 1.1/1.2 与外部主机通信的任何已知问题?该主机使用由 DigiCert 颁发的有效 SSL 证书。
在我的代码中,我已经尝试了一些方法来明确告诉 nodejs 使用 TLS 1.1 / 1.2,但这没有用。
var httpRequest = require("request"),
https = require('https');
https.globalAgent.options.secureProtocol = 'TLSv1_2_method'; // Instructing to use TLS 1.2
....
httpRequest.post('https://external-api-url.com', {
'json': true,
'body': params,
'timeout': 20000,
'jar': false,
'headers': {
"Arr-Disable-Session-Affinity": true
}
}, function(err, response, body) {
// Code to handle response.
});
除了 globalAgent,我还尝试从 agentOptions 以及直接从选项对象中设置 secureProtocol。 None 的方法奏效了。
任何帮助将不胜感激。
谢谢。
您的问题是 Azure 移动服务上的 NodeJS 版本问题。
Azure 移动服务上的 NodeJS 版本是 v0.8.28。可以在Azure Kudu Env页面https://<your_ams_name>.scm.azure-mobile.net/Env的"AppSettings"部分看到,如下图
但是,NodeJS从0.11.6版本开始将TLS 1.1/1.2添加到secureProtocol列表中,如下图。
因此,当外部实体决定停止支持 TLS 1.0 时,您的 nodejs 应用无法运行。
但是您可以按照 NodeJS 示例使用 Https APIs 支持 TLS 或请求模块 API 支持 TLS/SSL 协议来设置 options.key & options.cert 去做吧。 请参考https://nodejs.org/docs/v0.8.28/api/https.html#https_https_request_options_callback and https://github.com/request/request#tlsssl-protocol.
示例:
var fs = require('fs')
, path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key')
, request = require('request');
https.globalAgent.options.cert = certFile;
https.globalAgent.options.key = keyFil;
此致。