NodeJS &SSL - “错误的密码读取" [英] NodeJS & SSL - "bad password read"

查看:17
本文介绍了NodeJS &SSL - “错误的密码读取"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

节点未能为 SSL 通信创建安全上下文.

Node is failing to create a secure context for SSL communications.

具体来说,我正在尝试让远程通知在 iOS 上工作.我使用了一个名为 node-apn 的模块,它会引发此错误:

Specifically, I'm trying to get remote notifications to work on iOS. I use a module, called node-apn which throws this error:

Error: error:0906A068:PEM routines:PEM_do_header:bad password read
at Error (native)
at Object.createSecureContext (_tls_common.js:108:19)
at Object.exports.connect (_tls_wrap.js:852:21)
at apnSocket (/home/Slurp/node_modules/apn/lib/socket.js:56:19)
at Connection.<anonymous> (/home/Slurp/node_modules/apn/lib/connection.js:188:17)
at _fulfilled (/home/Slurp/node_modules/apn/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/Slurp/node_modules/apn/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/Slurp/node_modules/apn/node_modules/q/q.js:796:13)

虽然这似乎是一个通用错误,但与 APN 并没有真正相关.

This seems to be a generic error though, and isn't really related to APN specifically.

推荐答案

这是因为您在生成证书时指定了密码.这是任何想要使用它的人都必须提供的密码.

This is because you've specified a passphrase when generating the cert. This is a password that must be supplied by anyone wanting to use it.

向凭据添加密码字段可以解决问题.

Adding a passphrase field to the credentials solves the problem.

var credentials = {
    key: fs.readFileSync('XXX.key', 'utf8'),
    cert: fs.readFileSync('XXX.crt', 'utf8'),
    passphrase: 'XXXX'
}

var httpsServer = https.createServer(credentials, app);

这篇关于NodeJS &amp;SSL - “错误的密码读取"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆