我正在尝试从文件中加载 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)
我从一个工作资料库中检查了这个,我知道它适用于它的原作者。不过,出于某种原因,我的设置没有运行它。
最佳答案
我遇到了类似的问题。原来我使用的是 fs.readFileSync('file.pfx', 'utf8')
,这对于 PEM 文件是正确的,但是由于 PKCS12 文件是二进制的,所以你应该传入 fs.readFileSync('file.pfx')
.
关于javascript - Node.js - crypto.js - PFX header 太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24392571/