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

查看:353
本文介绍了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天全站免登陆