【发布时间】:2014-08-15 01:35:20
【问题描述】:
我正在尝试从文件中加载 PFX 和密码,以便发出 HTTPS 请求。在开始之前,我已经知道 PFX 很好,这不是问题。
我正在做以下事情:
config.options.pfx = fs.readFileSync('file.pfx');
config.options.passphrase = 'passphrase';
我正在将我的选项传递给代理。
config.options.agent = new https.Agent(options);
然后我尝试构建 rquest,但出现以下错误:
crypto.js:143
c.context.loadPKCS12(pfx, passphrase);
^
Error: header too long
at Object.exports.createCredentials (crypto.js:143:17)
at Object.exports.connect (tls.js:1334:27)
at Agent.createConnection (https.js:79:14)
at Agent.createSocket (http.js:1293:16)
at Agent.addRequest (http.js:1269:23)
at new ClientRequest (http.js:1416:16)
at Object.exports.request (https.js:123:10)
我从一个工作存储库中检查了这个,我知道这适用于它的原始作者。不过,出于某种原因,我的设置没有运行它。
【问题讨论】:
-
提示:pfx 只是一个被 MS 搞砸的 PKCS12 版本,因此一些加密工具可以与 pfx 一起使用,而其他工具则不能。尝试使用 openssl 工具生成本机 PKCS12 或将 pfx 转换为 PKCS12。
-
我在使用有效的 PFX (PKCS12) 文件时遇到了完全相同的问题,但没有解决方案。你解决了吗?
标签: javascript node.js https pfx