我正在使用HTTPS创建nodeJS服务器,类似于:
var https = require('https');
function listener(req, res) {
// for example, I wish this worked...
console.log(req.chosen_cipher)
}
var httpsd = https.createServer(SslOptions, listener);
httpsd.listen(8081, opts.ip);
如何找到SSL协商结果(特别是选定的密码),例如ECDHE-RSA-AES128-GCM-SHA256等。
我已经将请求和序列序列化了res对象,但似乎没有任何可能的候选人。
谢谢!
答案 0 :(得分:1)
Socket为req.client
。
因此,要获得密码和协议调用tlsSocket.getCipher()
:
function listener(req, res) {
console.log(req.client.getCipher());
// Possible result:
// { name: 'ECDHE-RSA-AES128-GCM-SHA256', version: 'TLSv1/SSLv3' }
}