I'm using the node package RequestJS v2.65.0 on node v4.1.2
I'm trying to read the SSL certificate from certain sites (eg. GitHub.com). This previously worked on node 0.12. On node 4.2.1, however, getPeerCertificate()
returns null
.
For example:
request({
url: 'https://github.com'
}, function (err, res, body) {
console.log('err:', err)
console.log('peerCertificate:',res.req.connection.getPeerCertificate());
console.log('authorized:',res.req.connection.authorized);
console.log('authorizationError:',res.req.connection.authorizationError);
});
will print out
err: null
peerCertificate: null
authorized: true
authorizationError: null
i.e. the secure connection is established but the certificate is null.
From my (basic) understanding, if the connection is authorized, there should be a peer certificate.
I've tried with a number of SSL sites, and the result is the same. Is there an option in request, a bug with Node 4, or a misunderstanding on my part about how SSL/TLS works in node?