node.js - SSL、Express、Nodejs:错误:错误:0909006C:PEM 例程:get_name:没有起始行
问题描述
我试图将证书添加到我的 nodeJs,Express 服务器,如下所示:
cert: fs.readFileSync('/path/to/private.key'),
key: fs.readFileSync('/path/to/your_domain_name.crt'),
ca: [
fs.readFileSync('path/to/CA_root.crt'),
fs.readFileSync('path/to/ca_bundle_certificate.crt')
]
我得到了这个错误
c.context.setKey(key, passphrase);
^
Error: error:0909006C:PEM routines:get_name:no start line
at Object.createSecureContext (_tls_common.js:151:17)
at Server.setSecureContext (_tls_wrap.js:1155:27)
at Server (_tls_wrap.js:1033:8)
at new Server (https.js:65:14)
at Object.createServer (https.js:89:10)
at Object.<anonymous> (********)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
library: 'PEM routines',
function: 'get_name',
reason: 'no start line',
code: 'ERR_OSSL_PEM_NO_START_LINE'
}
请问有人遇到这个问题吗?
提前致谢
解决方案
您可能在证书和密钥部分写入错误的文件名。key: 部分需要私钥文件名和 cert: 部分需要认证文件名。我在证书和密钥部分切换了您的文件名。
cert: fs.readFileSync('/path/to/your_domain_name.crt'),
key: fs.readFileSync('/path/to/private.key'),
ca: [
fs.readFileSync('path/to/CA_root.crt'),
fs.readFileSync('path/to/ca_bundle_certificate.crt')
]
推荐阅读
- javascript - 从js中另一个对象的值创建新对象
- r - 当我包含新的固定效果时,MEEM 中的错误
- r - 防止 rm_stopwords 函数创建列表
- html - CSS / SCSS - 访问具有未知子类型的子元素的子元素
- python - 使用带有 3 通道输入的 HoughCircles 时出错
- node.js - 傀儡师。Page.evluate() 没有运行或没有得到结果
- java - 缺少启动器的 Spring Boot 应用程序失败启动,这是不想要的
- php - 如何解决混合内容:使用带有 HTTPS 的 Wordpress 并且无法访问管理员?
- javascript - 确定元素是否在视口中 - 在滚动期间 - 返回 true / false
- python - python float 函数如何从 float(4.1E-2) 产生值 0.041?