gpt4 book ai didi

node.js - 不断收到错误 :0906D06C:PEM routines:PEM_read_bio:no start line

转载 作者:搜寻专家 更新时间:2023-10-31 23:11:37 42 4
gpt4 key购买 nike

在尝试联系 Xero API 时疯狂地尝试解决 Node.js 上的错误。

我使用了一堆“.cer”、“.crt”和“.pem”的组合。

我听从了许多 StackOverflow 海报的建议。

Node.js https pem error: error:0906D06C:PEM routines:PEM_read_bio:no start line

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:327:26)
at Xero.oa._createSignature (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/index.js:19:68)
at exports.OAuth._getSignature (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:90:15)
at exports.OAuth._prepareParameters (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:300:16)
at exports.OAuth._performSecureRequest (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:309:31)
at Xero.call (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/index.js:51:20)
at /Users/BeardedMac/projects/clause/clause-mean-stack/routes/external.js:47:10
at Layer.handle [as handle_request] (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/layer.js:95:5)
at /Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:330:12)
at next (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:271:10)
at expressInit (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/middleware/init.js:33:5)

有没有人有一些见解?

Xero API 说它需要一个 X509 证书……不过我什至没有打电话。

最佳答案

您需要一个 PEM 编码的 key ,因为 xero 模块只是调用 Node 的内置 crypto 模块来签署一些数据。这些类型的键以

开头
-----BEGIN RSA PRIVATE KEY-----

and end with

-----END RSA PRIVATE KEY-----

with base64-encoded data in between.

You can generate such a key using the openssl command-line utility:

openssl genrsa -out privateKey.pem 2048

Then read privateKey.pem in node like:

var fs = require('fs');
var privateKey = fs.readFileSync('/path/to/privateKey.pem');

// pass `privateKey` as the RSA private key to the `xero` module ...

关于node.js - 不断收到错误 :0906D06C:PEM routines:PEM_read_bio:no start line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38703443/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com