It looks like your problem is not with Hyper or Rust, it is with TLS. By default, when you establish connection via HTTPS, client verifies server certificate authenticity. The certificate needs to be signed by a trusted authority: for details, see, for example, this page.
To verify, use curl
:
$ curl https://localhost:1337/echo -X POST -v --insecure
...
* SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
...
< HTTP/2 200
< date: Sun, 12 Apr 2020 12:45:03 GMT
<
So this works fine. If you remove --insecure
flag, curl
will refuse to establish connection:
$ curl https://localhost:1337/echo -X POST -v
...
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
To fix this, you need to either:
- Use a properly-signed certificate instead of a self-signed one, or
- Configure your client not to verify certificate, or
- Configure your client to trust your particular self-signed certificate.
In production, your only choice is (1). While you are developing, you can get away with (2) or (3).