有没有一种方法可以进行休息呼叫,该呼叫需要客户端证书才能通过Node.js进行身份验证?
是的,您可以非常简单地执行此操作,这里使用常规的https请求即可;
var https = require('https'), // Module for https
fs = require('fs'); // Required to read certs and keys
var options = {
key: fs.readFileSync('ssl/client.key'), // Secret client key
cert: fs.readFileSync('ssl/client.crt'), // Public client key
// rejectUnauthorized: false, // Used for self signed server
host: "rest.localhost", // Server hostname
port: 8443 // Server port
};
callback = function(response) {
var str = '';
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
console.log(str);
});
}
https.request(options, callback).end();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句