2

我的 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);
};

我只是想知道

  1. 为什么请求模块抱怨 macu.com 而不是 facebook.com,而两者都拥有同一供应商的证书。
  2. macu的证书有什么问题?
  3. 为什么证书会为节点抛出错误但被浏览器接受。
4

1 回答 1

2

您的中间证书DigiCert High Assurance EV Root CA似乎已过期,请参阅 fe https://www.sslshopper.com/ssl-checker.html#hostname=www.macu.com

可能您的浏览器没有抱怨它,因为它已经安装了该中间证书的更新的有效版本(并使用它来证明签名机构的身份),而在您的节点实例上它仍然是旧版本(并且它向对方提出了这一点)。

编辑:进一步解释:当两方协商加密连接时,发起方将出示其证书和中间证书,以便对方可以验证它们。

如果您的浏览器已经DigiCert High Assurance EV Root CA在自己的证书缓存中存储了最新的中间证书,那么它可能会使用它来验证它所提供的证书。

但是,其他方(例如您的 node.js 模块)可能没有自己存储中间证书,因此他们依赖于所提供的内容。如果链中的一个证书过期,整个事情的验证将因此失败。

于 2015-01-06T09:48:56.817 回答