【问题标题】:Node.js won't load Let's Encrypt certificatesNode.js 不会加载 Let's Encrypt 证书
【发布时间】:2019-08-05 07:28:54
【问题描述】:
  https_options:
   { key: '/etc/letsencrypt/live/mywebsite.com/privkey.pem',
     cert: '/etc/letsencrypt/live/mywebsite.com/fullchain.pem' }

我只是使用上述选项执行 https.createServer 并收到此错误:

_tls_common.js:134
      c.context.setCert(cert);
                ^

Error: error:0909006C:PEM routines:get_name:no start line
    at Object.createSecureContext (_tls_common.js:134:17)
    at Server.setSecureContext (_tls_wrap.js:1017:27)
    at Server (_tls_wrap.js:897:8)
    at new Server (https.js:61:14)
    at Object.createServer (https.js:84:10)
    at startWWW (myserver.js:192:9)

我像这样测试了密钥/证书对:(正如其他人在其他问题、博客文章、论坛主题中所建议的那样)

openssl x509 -text -in /etc/letsencrypt/live/mywebsite.com/fullchain.pem
openssl rsa -text -in /etc/letsencrypt/live/mywebsite.com/privkey.pem

这两个命令都打印了多行看似有效的输出。

lsb_release -a | grep Description
Description: Ubuntu 18.04.2 LTS

【问题讨论】:

    标签: node.js lets-encrypt


    【解决方案1】:

    这应该可以解决它:

    key: fs.readFileSync('/etc/letsencrypt/live/mywebsite.com/privkey.pem', 'utf8'),
    

    对证书也做同样的事情。(例​​如以 utf8 编码读取)

    【讨论】:

    • 哦,我提供的是文件名而不是内容,我太傻了
    猜你喜欢
    • 2020-04-25
    • 2021-06-20
    • 2022-08-10
    • 2018-07-02
    • 2016-03-10
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多