Skip to content

goenning/sqlcertcache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc Go Report Card

sqlcertcache

SQL cache for acme/autocert written in Go.

Example

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

About

SQL Cache for Go acme/autocert

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages