我正在使用 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 等。
我已经序列化了 req 和 res 对象,但似乎没有任何可能的候选对象。
谢谢!
最佳答案
Socket当前连接是 req.client
。
因此,要获得密码和协议(protocol)调用 tlsSocket.getCipher()
:
function listener(req, res) {
console.log(req.client.getCipher());
// Possible result:
// { name: 'ECDHE-RSA-AES128-GCM-SHA256', version: 'TLSv1/SSLv3' }
}
关于node.js - 如何查看 NodeJS SSL 协商结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35446634/