diff options
author | Steve <nilslice@gmail.com> | 2016-12-28 16:23:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-28 16:23:44 -0800 |
commit | 806fdbe1e8839feb1bcc4e5e07aa7c144a429901 (patch) | |
tree | dacaed91abb57bc6891c1b2cb58a82fc0c9610fc /system/tls/enabledev.go | |
parent | 1f7a5b46b906da00ceccb03e7ff26627bb29a3dd (diff) | |
parent | 5c340ca57e876a556a5b57e5a7dd32b0ae288440 (diff) |
Merge pull request #26 from ponzu-cms/ponzu-dev
[tooling] Add Go command flag, auto-generate self-signed SSL for development
Diffstat (limited to 'system/tls/enabledev.go')
-rw-r--r-- | system/tls/enabledev.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/system/tls/enabledev.go b/system/tls/enabledev.go new file mode 100644 index 0000000..3550fc0 --- /dev/null +++ b/system/tls/enabledev.go @@ -0,0 +1,29 @@ +package tls + +import ( + "log" + "net/http" + "os" + "path/filepath" +) + +// EnableDev generates self-signed SSL certificates to use HTTPS & HTTP/2 while +// working in a development environment. The certs are saved in a different +// directory than the production certs (from Let's Encrypt), so that the +// acme/autocert package doesn't mistake them for it's own. +// Additionally, a TLS server is started using the default http mux. +func EnableDev() { + setupDev() + + pwd, err := os.Getwd() + if err != nil { + log.Fatalln("Couldn't find working directory to activate dev certificates:", err) + } + + vendorPath := filepath.Join(pwd, "cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "system", "tls") + + cert := filepath.Join(vendorPath, "devcerts", "cert.pem") + key := filepath.Join(vendorPath, "devcerts", "key.pem") + + log.Fatalln(http.ListenAndServeTLS(":10443", cert, key, nil)) +} |