node.js - 我们如何在 https.agent 中设置 SSL 证书密码?

标签 node.js https

我想将下面的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/

相关文章:

javascript - 如何使用 passport.js 登录的用户测试 sail.js Controller

node.js - 克服 Node 和 browserify 路径解析中的差异

android - 如何将应用程序本地存储同步到数据库?

ios - 在 iOS 9 中使用自签名证书发出 HTTPS 请求

WCF 安全 - 防止中间人攻击

c# - 找不到与具有绑定(bind) WSHttpBinding 的端点的方案 http 相匹配的基地址

javascript - 如何仅接受来 self 的 API 服务器的 cookie

node.js - 使用 Mocha 测试 locomotive.js

http - 为什么当我输入 http URL 时 firefox 立即请求 https?

有时会弹出 SSL 警告