Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goenning/sqlcertcache
SQL Cache for Go acme/autocert
https://github.com/goenning/sqlcertcache
autocert cache letsencrypt
Last synced: 28 days ago
JSON representation
SQL Cache for Go acme/autocert
- Host: GitHub
- URL: https://github.com/goenning/sqlcertcache
- Owner: goenning
- License: mit
- Created: 2018-07-28T11:29:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-31T20:50:47.000Z (over 6 years ago)
- Last Synced: 2024-11-02T19:41:40.511Z (3 months ago)
- Topics: autocert, cache, letsencrypt
- Language: Go
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/goenning/sqlcertcache?status.svg)](https://godoc.org/github.com/goenning/sqlcertcache) [![Go Report Card](https://goreportcard.com/badge/github.com/goenning/sqlcertcache)](https://goreportcard.com/report/github.com/goenning/sqlcertcache)
# sqlcertcache
SQL cache for [acme/autocert](https://godoc.org/golang.org/x/crypto/acme/autocert) written in Go.
## Example
```go
conn, err := sql.Open("postgres", "postgres://YOUR_CONNECTION_STRING")
if err != nil {
// Handle error
}cache, err := sqlcertcache.New(conn, "autocert_cache")
if err != nil {
// Handle error
}m := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("example.org"),
Cache: cache,
}s := &http.Server{
Addr: ":https",
TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
}s.ListenAndServeTLS("", "")
```## Performance
This is just a reminder that autocert has an internal in-memory cache that is used before quering this long-term cache.
So you don't need to worry about your SQL database being hit many times just to get a certificate. It should only do once per process+key.## Thanks
Inspired by https://github.com/danilobuerger/autocert-s3-cache
## License
MIT