我正在尝试从文件中加载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')
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句