Node.js – crypto.js – PFX头太长

我正试图从一个文件加载一个PFX和口令,以便我可以做一个HTTPS请求。 在我开始之前,我已经知道PFX是好的,这不是问题。

我正在做以下事情:

config.options.pfx = fs.readFileSync('file.pfx'); config.options.passphrase = 'passphrase'; 

我正在把我的select权交给代理人。

 config.options.agent = new https.Agent(options); 

然后我尝试build立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')