See this.
a.js
:
const https = require('https');
https.get({host: 'registry.bower.io'}, res => {
console.log(res.statusCode);
}).on('error', e => {
console.log(e);
});
b.js
:
const https = require('https');
https.get({host: 'registry.bower.io', rejectUnauthorized: false}, res => {
// https.get({host: 'registry.bower.io', agent: https.Agent({rejectUnauthorized: false})}, res => {
console.log(res.statusCode);
}).on('error', e => {
console.log(e);
});
c.js
:
const https = require('https');
const fs = require('fs');
const ca = fs.readFileSync('a.pem');
https.get({host: 'registry.bower.io', ca: ca}, res => {
// https.get({host: 'registry.bower.io', agent: https.Agent({ca: ca})}, res => {
console.log(res.statusCode);
}).on('error', e => {
console.log(e);
});
$ docker run --rm -it ruby:2.3.8-alpine3.8 sh
/ # apk add curl nodejs
/ # curl https://letsencrypt.org/certs/isrgrootx1.pem -o a.pem
/ # node a.js
{ Error: certificate has expired
at TLSSocket.<anonymous> (_tls_wrap.js:1116:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:643:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:473:38) code: 'CERT_HAS_EXPIRED' }
/ # node b.js
302
/ # node d.js
302
/ # NODE_TLS_REJECT_UNAUTHORIZED=0 node a.js
302