Kushal
Kushal

Reputation: 2791

How we can set SSL cert password in https.agent?

I want to convert the below PHP code into nodejs. For curl operation, I'm using https packages.

curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $SSlCertPwd);

How we can set SSL cert password in https.agent?

Please help me.

Upvotes: 3

Views: 3311

Answers (1)

Sergey Lapin
Sergey Lapin

Reputation: 2693

https.Agent takes an object with options, including passphrase:

const options = {
  hostname: '...',
  port: 443,
  path: '...',
  method: '...',
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
  passphrase: 'super secret'
};
const agent = new https.Agent(options);

Upvotes: 3

Related Questions