📚 sslmgr - Awesome Go Library for Security
SSL certificates made easy with a high level wrapper around acme/autocert.
🏷️ Security
📂 Libraries that are used to help make your application more secure.
⭐ 26 stars
Detailed Description of sslmgr
Simple Secure Server
Prerequisites:
- Your server must be reachable through the provided domain name, this is how LetsEncrypt verifies domain ownership and grants your server a trusted certificate
With Default Values:
ss, err := sslmgr.NewSecureServer(handler, "yourhostname.com")
if err != nil {
log.Fatal(err)
}
ss.ListenAndServe()
Note: This option uses the file system as the certificate cache. If your use case does not have a persistent file system, you should provide a value for CertCache in the ServerConfig as shown below.
With Optional Values:
(Using the certcache library to define a cache)
ss, err := sslmgr.NewServer(sslmgr.ServerConfig{
Hostnames: []string{os.Getenv("CN_FOR_CERTIFICATE")},
HTTPPort: ":80",
HTTPSPort: ":443",
Handler: h,
ServeSSLFunc: func() bool {
return strings.ToLower(os.Getenv("PROD")) == "true"
},
CertCache: certcache.NewLayered(
certcache.NewLogger(),
autocert.DirCache("."),
),
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
IdleTimeout: 25 * time.Second,
GracefulnessTimeout: 5 * time.Second,
GracefulShutdownErrHandler: func(e error) {
log.Fatal(e)
},
})
if err != nil {
log.Fatal(err)
}
ss.ListenAndServe()