I am not sure that I am not changing the code, but you can do it this way:
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 produce the result as follows:
Listening...
Connecting..
Tls.connect authorized
Cipher: {"name":"ECDHE-RSA-AES128-GCM-SHA256","version":"TLSv1/SSLv3"}
Protocol: "TLSv1.2"
source
share