caddyserver /certmagic
Automatic HTTPS for any Go program: fully-managed TLS certificate issuance and renewal
★ 5,617⑂ 368👁 59⑃ 187● 237▤ 34
-1
日增长
5,617
stars
368
forks
59
watchers
187
prs
237
issues
34
releases
README
Easy and Powerful TLS Automation
The same library used by the Caddy Web Server
Caddy's automagic TLS features—now for your own Go programs—in one powerful and easy-to-use library!
CertMagic is the most mature, robust, and powerful ACME client integration for Go... and perhaps ever.
With CertMagic, you can add one line to your Go application to serve securely over TLS, without ever having to touch certificates.
Instead of:
go
// plaintext HTTP, gross 🤢
http.ListenAndServe(":80", mux)
Use CertMagic:
go
// encrypted HTTPS with HTTP-HTTPS redirects - yay! 🔒😍
certmagic.HTTPS([]string{"example.com"}, mux)
That line of code will serve your HTTP router mux over HTTPS, complete with HTTP-HTTPS redirects. It obtains and renews the TLS certificates. It staples OCSP responses for greater privacy and security. As long as your domain name points to your server, CertMagic will keep its connections secure.
Compared to other ACME client libraries for Go, only CertMagic supports the full suite of ACME features, and no other library matches CertMagic's maturity and reliability.
CertMagic - Automatic HTTPS using Let's Encrypt
===============================================
Menu
- Features
- Requirements
- Installation
- Usage
- Package Overview
- Certificate authority
- The Config type
- Defaults
- Providing an email address
- Rate limiting
- Development and testing
- Examples
- Serving HTTP handlers with HTTPS
- Starting a TLS listener
- Getting a tls.Config
- Advanced use
- Wildcard Certificates
- Behind a load balancer (or in a cluster)
- The ACME Challenges
- HTTP Challenge
- TLS-ALPN Challenge
- DNS Challenge
- On-Demand TLS
- Storage
- Cache
- Events
- ZeroSSL
- FAQ
- Contributing
- Project History
- Credits and License
Features
- Fully automated certificate management including issuance and renewal
- One-line, fully managed HTTPS servers
- Full control over almost every aspect of the system
- HTTP-HTTPS redirects
- Multiple issuers supported: get certificates from multiple sources/CAs for redundancy and resiliency
- Solves all 3 common ACME challenges: HTTP, TLS-ALPN, and DNS (and capable of others)
- Most robust error handling of _any_ ACME client
- Challenges are randomized to avoid accidental dependence
- Challenges are rotated to overcome certain network blockages
- Robust retries for up to 30 days
- Exponential backoff with carefully-tuned intervals
- Retries with optional test/staging CA endpoint instead of production, to avoid rate limits
- Written in Go, a language with memory-safety guarantees
- Powered by ACMEz, _the_ premier ACME client library for Go
- All libdns DNS providers work out-of-the-box
- Pluggable storage backends (default: file system)
- Pluggable key sources
- Wildcard certificates
- Automatic OCSP stapling (done right) keeps your sites online!
- Will automatically attempt to replace revoked certificates!
- Staples stored to disk in case of responder outages
-Top issues
#241Higher-level storage implementations20 comments · 2023-06-27#308CacheUnmanagedCertificatePEMBytes returns only the first certificate and omits intermediate and root certificates. What am I doing wrong?13 comments · 2024-09-08#203Request support for more dynamic mTLS client cert/csr management12 comments · 2022-08-24#226Q: What's the correct way to setup statically managed domains + dynamically added domains?11 comments · 2023-04-13#158Add interface for client-side encryption10 comments · 2021-12-16#298Allow specific issuers for specific on-demand domains7 comments · 2024-07-01#294Allow Certmagic to generate 'next' private key to allow safe TLSA/DANE deployment and rollover6 comments · 2024-06-20#356Certs are saved using `NamesKey`, but are loaded using the CommonName5 comments · 2025-10-08
Latest release
v0.25.6 v0.25.6 2026-09-30Almost forgot to update the ZeroSSL dependency which uses the new Authorization: ApiKey ... header. Full Changelog: https://github.com/caddyserver/certmagic/compare/v0.25.5...v0.25.6