问题描述
我想从我的服务器检查SSL证书是否在其他服务器/域上有效。有什么方法可以检查这个吗?
I want to check from my server, if the SSL certificate is valid on another server/domain. Is there any way how I can check this?
我想我需要使用 API,但我不确定。
I think I need to use the https API from NodeJS, but I'm not sure.
推荐答案
当你使用其https库从NodeJS发出SSL请求,它将负责验证它所联系的服务器的有效性。
When you make an SSL request from NodeJS using its https library, it will take care of the job of verifying the validity of the server it's contacting.
来自:
此外,您可以断言 res.socket.authorized响应中的
属性:
Further more, you can assert the res.socket.authorized
attribute in the response:
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();
您还可以使用 res.socket.getPeerCertificate()
获取服务器证书的详细信息。
You can also use res.socket.getPeerCertificate()
to get detailed information on the server certificate.
这篇关于NodeJS检查SSL认证其他主机的有效性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!