title: Error: CERT_HAS_EXPIRED in Node.js request module (macu vs facebook)
body: <p>My WebProxy is built in node. I am using <code>request</code> module to fetch content from given Url. I am getting <strong>CERT_HAS_EXPIRED error</strong> for <a href="https://www.macu.com" rel="nofollow">https://www.macu.com</a> while the site opens fine in browser.</p>
  
  <h3>My Investigations</h3>
  
  <p>I investigated and checked the certificate details via <strong>Chrome</strong> but I see that certificate is not expired. I do not understand the issue with this website's certificate.</p>
  
  <p>I thought this could be an issue with the vendor not present in the list of Node.js. I tried upgrading npm and node versions but no success. Moreover <a href="https://www.facebook.com" rel="nofollow">https://www.facebook.com</a>'s certificate is also issued by <strong>DigiCert High Assurance CA-3</strong> vendor which clearly says that this vendor is present in Node.js CA list.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>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);
  };
  </code></pre>
  
  <p>I just want to know </p>
  
  <ol>
  <li>Why Request module complains for macu.com but not for facebook.com while both have certificates by same vendor.</li>
  <li>What is the issue with macu's certificate ?</li>
  <li>Why certificate is throwing error for node but is accepted by browser.</li>
  </ol>