Keep getting error:0906D06C:PEM routines:PEM_read_bio:no start line
Keep getting error:0906D06C:PEM routines:PEM_read_bio:no start line
在尝试联系 Xero API 时试图解决 Node.js 上的错误变得疯狂。
我使用了一堆“.cer”、“.crt”和“.pem”的组合。
我听从了许多 Whosebug 海报的建议。
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 编码的密钥,因为 xero
模块仅调用节点的内置 crypto
模块来签署一些数据。这些类型的键以
开头
-----BEGIN RSA PRIVATE KEY-----
并以
结束
-----END RSA PRIVATE KEY-----
中间有 base64 编码的数据。
您可以使用 openssl
命令行实用程序生成这样的密钥:
openssl genrsa -out privateKey.pem 2048
然后在节点中读取privateKey.pem
,如:
var fs = require('fs');
var privateKey = fs.readFileSync('/path/to/privateKey.pem');
// pass `privateKey` as the RSA private key to the `xero` module ...
检查您的证书格式。回车 return(\r) 和换行符(\n) 应该以 .cer 或 .crt 格式存在。邮递员期待这一点。
这可以通过在记事本中打开来验证。
在尝试联系 Xero API 时试图解决 Node.js 上的错误变得疯狂。
我使用了一堆“.cer”、“.crt”和“.pem”的组合。
我听从了许多 Whosebug 海报的建议。
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 编码的密钥,因为 xero
模块仅调用节点的内置 crypto
模块来签署一些数据。这些类型的键以
-----BEGIN RSA PRIVATE KEY-----
并以
结束-----END RSA PRIVATE KEY-----
中间有 base64 编码的数据。
您可以使用 openssl
命令行实用程序生成这样的密钥:
openssl genrsa -out privateKey.pem 2048
然后在节点中读取privateKey.pem
,如:
var fs = require('fs');
var privateKey = fs.readFileSync('/path/to/privateKey.pem');
// pass `privateKey` as the RSA private key to the `xero` module ...
检查您的证书格式。回车 return(\r) 和换行符(\n) 应该以 .cer 或 .crt 格式存在。邮递员期待这一点。 这可以通过在记事本中打开来验证。