如何在https.agent中设置SSL证书密码



我想将下面的PHP代码转换为nodejs。对于curl操作,我使用https包。

curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $SSlCertPwd);

如何在https.agent中设置SSL证书密码?

请帮帮我。

https.Agent接受一个具有选项的对象,包括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);

最新更新