我想将下面的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);
关于node.js - 我们如何在 https.agent 中设置 SSL 证书密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65108098/