当您使用NodeJS的https库从NodeJS发出SSL请求时,它将完成验证所联系服务器的有效性的工作。
rejectUnauthorized:如果为true,则根据提供的CA列表验证服务器证书。如果验证失败,则发出“错误”事件。验证在发送HTTP请求之前在连接级别进行。默认为true
此外,您可以res.socket.authorized在响应中声明属性:
var https = require('https');
var options = {
host: 'google.com',
method: 'get',
path: '/'
};
var req = https.request(options,
function (res) {
console.log('certificate authorized:' + res.socket.authorized);
});
req.end();
Run Code Online (Sandbox Code Playgroud)
您也可以使用res.socket.getPeerCertificate()获取有关服务器证书的详细信息。
| 归档时间: |
|
| 查看次数: |
2415 次 |
| 最近记录: |