Confused about https cert generating for testing locally

The documentation seems to suggest that we could test Caddy locally, by adding an existing domain to /etc/hosts and then serving over caddy, but the certificate registration fails since the domain points to the real server IP.

Did I misunderstand what the documentation is suggesting, or am I doing something wrong?

For example, for ustunozgur.org which is currently hosted elsewhere, I have the following Caddyfile:

ustunozgur.org

I get the following error:
`
sudo caddy
Activating privacy features…2016/06/23 15:46:35 [ustunozgur.org] failed to get certificate: acme: Error 400 - urn:acme:error:tls - Failed to connect to 104.31.91.243:443 for TLS-SNI-01 challenge
Error Detail:
Validation for ustunozgur.org:443
Resolved to:
104.31.91.243
104.31.90.243
Used: 104.31.91.243

`

Obtaining a certificate and serving a site locally at a custom domain are two different things. You can use /etc/hosts to load your site over any hostname, for example, mytestsite or a real domain that exists elsewhere like example.com, but you can’t use /etc/hosts to get a certificate for that name.

If you want to run a local dev site over HTTPS with any hostname you want, you should use tls self_signed (available in 0.9 beta).

1 Like

Thanks. I was a bit confused by the introduction, thinking I could get a cert for matt.life from the examples :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.