I know importing the certificate into browser trust store can dismiss the warning, but is it the only workaround? Is it possible using a domain (with a valid SSL) to reverse proxy the localhost web server: redirecting user's request to the localhost?
If you have an external domain and a valid certificate for it (i.e. both certificate and key) you could configure your localhost server to serve this domain and use this certificate. To make sure that any local requests to this domain actually reach your local server instead of the external IP you need the appropriate name resolution though. This can be done for example by modifying the hosts
file (i.e. /etc/hosts
on UNIX, c:\Windows\System32\Drivers\etc\hosts
on Windows).
In other words:
example.com
instead of localhost
, i.e. set certificate and key you have for example.com
and configure the expected name to example.com
.hosts
file to resolve example.com
with 127.0.0.1
.https://example.com
. Due to the changed local hosts
file it will use 127.0.0.1
as the IP address for example.com
and thus access the local web server. This will provide the publicly trusted certificate for example.com
so that the browser will not complain (issuer CA is trusted and subject of certificate matches the URL).Remember to change your local hosts
file back if you want to access the real (external) example.com
.