Sì, lo si può fare semplicemente, qui usando una normale richiesta 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();
fonte
2014-05-10 07:33:05
Come passare un JSON o XML nel corpo della richiesta se utilizzo questo approccio? –
@AnandDivakaran Se hai bisogno del codice completo per una richiesta di post, [questa risposta] (http://stackoverflow.com/a/6158966/477878) mostra come farlo. In questo caso, dovrai solo sostituire 'http' con' https' e aggiungere le opzioni chiave e cert mostrate sopra alle 'post_options' affinché i certificati client funzionino. –
Grazie; Mi sono imbattuto in ago e ha funzionato per me –