RFC: HTTPS Support (draft) #33
Replies: 2 comments 1 reply
-
Re: Caddy, it has everything you need for HTTPS, including a fully-automated self-signed CA. Basically, you can have what mkcert does, but automatically, including automatic trust store installation on the local host. So you wouldn't need the extra tooling of mkcert at all. I recommend using CertMagic over autocert, as CertMagic has a more robust ACME implementation and is more flexible, also it supports a lot of DNS providers for using the DNS challenge (crucial for when domains aren't on public networks). Not to mention CertMagic has more features that are useful for advanced use cases with minimal hassle. For example, CertMagic can scale up to multiple instances so when you deploy into production they can automatically coordinate resources and maintenance together.
If you can't get a certificate in the moment it is needed, that's unfortunate. I recommend always getting them ahead of time if you can, but Caddy+CertMagic is also excellent at On-Demand TLS. Let me know if you have any questions. |
Beta Was this translation helpful? Give feedback.
-
@mholt what a pleasant surprise! Thank you for sharing your expertise with us. It sounds like:
How does Caddy handle expirations in the ideal case when you get certificates ahead of time? |
Beta Was this translation helpful? Give feedback.
-
Automatic HTTPS Support
To setup HTTPS, you can define a
Certificate
function in theweb
package.The certificates are generated on the fly and cached for future requests. The workflow is the same for development and production.
Development
In development, Bud relies on @FiloSottile's excellent mkcert package for setting up HTTPS on localhost. Once you've installed mkcert, run the following command in your terminal:
This will install a certificate authority (CA) locally. You only need to do this once. With the trusted CA in place, Bud can now generate locally-trusted certificates:
Production
For production, you just need to alter the domain. The
Certificate
function supports automatic Dependency Injection, so it's straightforward to pass an environment through:Under the hood we rely on https://golang.org/x/crypto/acme/autocert.
By default, the certificate package uses LetsEncrypt to generate and cache certificates as needed.
Open Questions
Certificate
too generic?cert
,https
ortls
)Resources
Beta Was this translation helpful? Give feedback.
All reactions