The following additional options from tls.connect() are also accepted: ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder, key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext.
// Example piece of https code
const key,cert,passphrase, ca; //Will have correct values. Leaving it blank for brevity.
const options = {
host: 'https',
path: '',
method: post,
headers: {
'Content-Type': 'application/json',
'Contentlength': 100
},
key,
cert,
passphrase,
ca,
rejectUnauthorized: false,
checkServerIdentity: function (host, cert) {
return undefined;
}
};
options.agent = new https.Agent(options);
const req = https.request(options, (res) => {
console.log('All OK. Server matched our pinned cert or public key');
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', console.log);
});
There should be an ability to provide a passphrase for a private key. Https.request supports it. From https://nodejs.org/api/https.html#https_https_request_options_callback