我的 WebProxy 内置在节点中。我正在使用request
模块从给定的 Url 中获取内容。当网站在浏览器中正常打开时,我收到https://www.macu.com的CERT_HAS_EXPIRED 错误。
我的调查
我通过Chrome调查并检查了证书详细信息,但我看到证书没有过期。我不明白这个网站证书的问题。
我认为这可能是 Node.js 列表中不存在的供应商的问题。我尝试升级 npm 和 node 版本但没有成功。此外https://www.facebook.com的证书也是由DigiCert High Assurance CA-3供应商颁发的,它清楚地表明该供应商存在于 Node.js CA 列表中。
这是代码:
var request = require('request');
function getContent(urlOptions) {
request.get(urlOptions, function(error, response, body) {
if (error) console.log('Error:' + error);
if (body) {
console.log('Body:' + body);
}
});
}
exports.init = function() {
var urlOptions = {
headers: {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36'
},
secureProtocol: 'TLSv1_method'
};
/* URL options for macu.com domain */
urlOptions.url = 'https://www.macu.com/mystyle-checking';
urlOptions.headers.host = urlOptions.headers.Host = 'www.macu.com';
// urlOptions.rejectUnauthorized = false; // Works when this option is set but it may cause security issue
getContent(urlOptions);
urlOptions.url = 'https://www.facebook.com';
urlOptions.headers.host = urlOptions.headers.Host = 'www.facebook.com';
getContent(urlOptions);
};
我只是想知道
- 为什么请求模块抱怨 macu.com 而不是 facebook.com,而两者都拥有同一供应商的证书。
- macu的证书有什么问题?
- 为什么证书会为节点抛出错误但被浏览器接受。