代码之家  ›  专栏  ›  技术社区  ›  Yan Li

节点。js https示例,错误,连接到本地主机时出现未知SSL协议错误

  •  21
  • Yan Li  · 技术社区  · 9 年前

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

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

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

    但我会遇到这样的错误

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

    为什么?

    1 回复  |  直到 8 年前
        1
  •  67
  •   Community CDub    8 年前

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

    这个是错误的:

    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