In node i'm using npm module "request" : https://www.npmjs.com/package/request
I want to know how i can retrieve from response the TLS version used, TLS1.0, TLS1.1, TLS1.2.
var request = require("request");
request.get({url: "https://www.google.com/"}, function(err, response, body) {
console.log(response.req.connection._tlsOptions); // ??
process.exit(0);
});
One of our provider will soon manage only TLS1.2 and i want to know which version is used now in order to know if i have to specify secureProtocol: "TLSv1_2_method" for this provider.
require('request').get("https://www.google.com/").on('response',
(response) =>
console.log(response.socket.getProtocol())
); ""
tlsSocket.getProtocol()
can not be used in callback as connection is closed by then, and TLS connection metadata is no longer available.
https://nodejs.org/api/tls.html#tls_class_tls_tlssocket
Methods that return TLS connection metadata (e.g. tls.TLSSocket.getPeerCertificate() will only return data while the connection is open.
You can send a request to howsmyssl.com
var allData = ''
require('request')({
uri: 'https://howsmyssl.com/a/check'
}).on('data', function(data) {
allData += data.toString()
}).on('end', function() {
console.log(JSON.parse(allData).tls_version)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With