【问题标题】:node.js https example ,error, Unknown SSL protocol error in connection to localhostnode.js https 示例,错误,连接到 localhost 时出现未知 SSL 协议错误
【发布时间】:2016-04-22 12:14:49
【问题描述】:

我使用这些链接中的简单示例:

a link[a 如何在 Node.js 中创建 HTTPS 服务器?]

a link[a 如何创建https服务器? docs.nodejitsu.com]

但我得到类似的错误

curl: (35) 连接到 localhost:-9838 时出现未知 SSL 协议错误

为什么?

【问题讨论】:

    标签: node.js https


    【解决方案1】:

    我使用错误的方式创建证书。

    这个错了:

    openssl genrsa -out key.pem
    openssl req -new -key key.pem -out csr.pem
    openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
    

    这是创建可以使用的证书的方法:

    openssl genrsa -out client-key.pem 2048
    openssl req -new -key client-key.pem -out client.csr
    openssl x509 -req -in client.csr -signkey client-key.pem -out client-cert.pem
    

    【讨论】:

    • 太棒了!我正在寻找这个。但为什么这是错误的方式?能解释一下就好了
    • 我是菜鸟所以不知道答案:)
    • 对我来说重要的区别是 genrsa 命令上的 2048 - 没有它,默认密钥是一个弱的 512 位。我能找到的该错误代码的唯一参考是Apple source code,它是errSSLPeerInternalError(但距离errSSLPeerInsufficientSecurity只有一个距离)。
    • @YanLi 你太棒了!我花了一整夜的时间以错误的方式工作并排除了我的 mac、chrome 和上帝知道的各种问题。尝试了你的方法,它的工作原理!谢谢!
    • -days 9999 参数也适用于第二种方法
    猜你喜欢
    • 2016-03-09
    • 2018-04-27
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 2014-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多