diff options
author | Kali Kaneko <kali@leap.se (leap communications)> | 2019-07-05 19:07:32 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se (leap communications)> | 2019-07-05 19:07:32 +0200 |
commit | 638ff1ddac9d45ad442e78bd698a39fa3469eb6d (patch) | |
tree | cb84a27e2f58209fd3c1b8d5e1c3b5bc1479f8fb | |
parent | ba4d83dd8db90f77a861186801ac0fccd015aaef (diff) |
add tls
-rw-r--r-- | main.go | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -45,6 +45,10 @@ func main() { var caCrt = flag.String("caCrt", "", "path to the CA public key") var caKey = flag.String("caKey", "", "path to the CA private key") var port = flag.Int("port", 8000, "port where the server will listen") + var notls = flag.Bool("notls", false, "disable TLS on the service") + var tlskey = flag.String("tls_key", "", "path to the key file for TLS") + var tlscrt = flag.String("tls_crt", "", "path to the cert file for TLS") + flag.Parse() flag.Parse() @@ -66,5 +70,11 @@ func main() { httpFileHandler("/1/configs.json", "./public/1/configs.json") httpFileHandler("/1/service.json", "./public/1/service.json") - log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil)) + pstr := ":" + strconv.Itoa(*port) + + if *notls == true { + log.Fatal(http.ListenAndServe(pstr, nil)) + } else { + log.Fatal(http.ListenAndServeTLS(pstr, *tlscrt, *tlskey, nil)) + } } |