github.com/rpdict/ponzu@v0.10.1-0.20190226054626-477f29d6bf5e/system/tls/enabledev.go (about) 1 package tls 2 3 import ( 4 "log" 5 "net/http" 6 "os" 7 "path/filepath" 8 ) 9 10 // EnableDev generates self-signed SSL certificates to use HTTPS & HTTP/2 while 11 // working in a development environment. The certs are saved in a different 12 // directory than the production certs (from Let's Encrypt), so that the 13 // acme/autocert package doesn't mistake them for it's own. 14 // Additionally, a TLS server is started using the default http mux. 15 func EnableDev() { 16 setupDev() 17 18 pwd, err := os.Getwd() 19 if err != nil { 20 log.Fatalln("Couldn't find working directory to activate dev certificates:", err) 21 } 22 23 vendorPath := filepath.Join(pwd, "cmd", "ponzu", "vendor", "github.com", "rpdict", "ponzu", "system", "tls") 24 25 cert := filepath.Join(vendorPath, "devcerts", "cert.pem") 26 key := filepath.Join(vendorPath, "devcerts", "key.pem") 27 28 log.Fatalln(http.ListenAndServeTLS(":10443", cert, key, nil)) 29 }