Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/adrianosela/sslmgr

A layer of abstraction the around acme/autocert certificate manager (Golang)
https://github.com/adrianosela/sslmgr

acme acme-client acme-dns acme-v2 autocert certificate go golang graceful graceful-shutdown https https-server server ssl ssl-certificate ssl-certificates tls tls-certificate x509 x509certificates

Last synced: about 2 months ago
JSON representation

A layer of abstraction the around acme/autocert certificate manager (Golang)

Awesome Lists containing this project

README

        

# Simple Secure Server

[![Go Report Card](https://goreportcard.com/badge/github.com/adrianosela/sslmgr)](https://goreportcard.com/report/github.com/adrianosela/sslmgr)
[![Documentation](https://godoc.org/github.com/adrianosela/sslmgr?status.svg)](https://godoc.org/github.com/adrianosela/sslmgr)
[![GitHub issues](https://img.shields.io/github/issues/adrianosela/sslmgr.svg)](https://github.com/adrianosela/sslmgr/issues)
[![license](https://img.shields.io/github/license/adrianosela/sslmgr.svg)](https://github.com/adrianosela/sslmgr/blob/master/LICENSE)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#security)

#### 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](https://godoc.org/github.com/adrianosela/sslmgr#ServerConfig) as shown below.

#### With Optional Values:

(Using the [certcache](https://godoc.org/github.com/adrianosela/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()
```