javascript - Node.js - crypto.js - PFX header 太长

标签 javascript node.js https pfx

我正在尝试从文件中加载 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/

相关文章:

javascript - jQuery 中 if(something.length) 的含义

javascript - Node.js 中的 CORS 问题失败

ssl - 带有 client.crt 和 client.key 的 https 请求

javascript - 如何使用 JSON 数据创建动态表?

javascript - 当 <div> 失去焦点时 jQuery 动画

node.js - 你如何使用 node-irc 登录?

node.js - Passport Saml 循环

windows - 如何解决 Geoserver Jetty "Module not found ssl"错误?

azure - 我可以在 Azure Web App 的同一主机名上使用两个 SSL 证书吗?

javascript - 不理解 Node.js 中的 Cookie