Reputation: 71961
I'd like to log which versions of TLS my Node app is using, if possible without changing any code.
I've tried both NODE_DEBUG=tls,http
, and DEBUG=*
which of course added lots of info to the logs, but nothing about the TLS versions in use.
Is this possible ?
Upvotes: 4
Views: 1039
Reputation: 30675
I'm not sure about not changing code, but you can log like this:
const tls = require('tls');
const url = 'someurl';
console.log('Connecting..');
const socket = tls.connect(443, url, () => {
console.log('Tls.connect', socket.authorized ? 'authorized' : 'unauthorized');
console.log('Cipher: ' + JSON.stringify(socket.getCipher()));
console.log('Protocol: ' + JSON.stringify(socket.getProtocol()));
});
This will give an output like this:
Listening...
Connecting..
Tls.connect authorized
Cipher: {"name":"ECDHE-RSA-AES128-GCM-SHA256","version":"TLSv1/SSLv3"}
Protocol: "TLSv1.2"
Upvotes: 1