Closed
Description
Requesting from the same host twice using https will only return the certificate on the first connection.
var req = https.request(url);
req.once('socket', function(socket) {
socket.once('secureConnect', function() {
var cert = socket.getPeerCertificate(); // detailed or not does not seem to matter
// cert is ok the first time, empty the second time.
});
});
I would expect to get back the cert every time even if the connection is reused.
I'm caching it now but it's a bad workaround as other code could be using https.request
to connect to the same host without using the cache which means that my code will never see the cert.
Also caching the cert means I'm relying on the assumption that the fact that I did not get a cert this time means the cert in my cache still applies and is valid.