Node.js HTTPS server ERR_EMPTY_RESPONSE

前端 未结 2 527
面向向阳花
面向向阳花 2020-12-19 05:29

I created the server.key and server.csr files using openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr. I created a SSL certificate with sta

相关标签:
2条回答
  • 2020-12-19 05:48

    You can troubleshoot errors by connecting to your application with curl --insecure --verbose. Generally you shouldn't use an SSL certificate on more than one host. You can make a self-signed one to test locally and use the startssl one in production. But in any case, the CN in the cert needs to match the hostname used to connect to the site to avoid annoying browser warnings. You can always make up a domain name for your machine like sam.local and put that in your /etc/hosts file and use that in your self-signed certificate as well as your browser address bar.

    0 讨论(0)
  • 2020-12-19 05:53

    I know this is an old question, but I encountered the same thing today. I would get the same result back from express (ERR_EMPTY_RESPONSE).

    The fix? Be sure to specify https, and not http, in your test browser (e.g., https://localhost:8443).

    If you previously used middleware to forward all http requests to https you wouldn't have seen this problem before. Also, expect your browser to complain about the certificate, but proceed through anyway (in chrome this takes several clicks).

    0 讨论(0)
提交回复
热议问题