github.com/bosssauce/ponzu@v0.11.1-0.20200102001432-9bc41b703131/system/tls/enabledev.go (about)

     1  package tls
     2  
     3  import (
     4  	"log"
     5  	"net/http"
     6  	"path/filepath"
     7  
     8  	"github.com/ponzu-cms/ponzu/system/cfg"
     9  )
    10  
    11  // EnableDev generates self-signed SSL certificates to use HTTPS & HTTP/2 while
    12  // working in a development environment. The certs are saved in a different
    13  // directory than the production certs (from Let's Encrypt), so that the
    14  // acme/autocert package doesn't mistake them for it's own.
    15  // Additionally, a TLS server is started using the default http mux.
    16  func EnableDev() {
    17  	setupDev()
    18  
    19  	vendorPath := cfg.TlsDir()
    20  	cert := filepath.Join(vendorPath, "devcerts", "cert.pem")
    21  	key := filepath.Join(vendorPath, "devcerts", "key.pem")
    22  
    23  	log.Fatalln(http.ListenAndServeTLS(":10443", cert, key, nil))
    24  }