title: 'request' : Error: { Error: self signed certificate in certificate chain
body: <p>I'm trying to fetch some information from below mentioned API and I'm getting below error </p>
  
  <pre><code>const request = require('request');
  
  
  var options = {
      url : 'https://example.com',
  }
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>var options = {
    url : 'https://example.com',
    agentOptions: {
      ca: fs.readFileSync('ca.pem')
    }
  }
  
  console.log(options)
  
  request(options, function (error, response, body) {
    console.log('error:', error); 
    console.log('statusCode:', response &amp;&amp; response.statusCode); 
    console.log('body:', body ); 
  });
  
  
  
    error: { Error: self signed certificate in certificate chain
          at Error (native)
          at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:1092:38)
          at emitNone (events.js:86:13)
          at TLSSocket.emit (events.js:185:7)
          at TLSSocket._finishInit (_tls_wrap.js:610:8)
          at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' }
  </code></pre>
  
  <p>sample pem file </p>
  
  <pre><code>-----BEGIN CERTIFICATE-----
  Key
  -----END CERTIFICATE-----
  </code></pre>
  
  <p><strong>I don't want to use either NODE_TLS_REJECT_UNAUTHORIZED='0' or  rejectUnauthorized: false</strong></p>