diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-21 15:09:16 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-21 15:09:16 -0700 |
commit | 882a8166ce3095d390871ac6890974eb4c0d326d (patch) | |
tree | 65d6c3ee18ba944d0ed005632a5366195ede81f0 /system/tls/init.go | |
parent | a6e8f666f20f23017dcbe898f1614776427c49f8 (diff) |
adding better error handling to check for nil values
Diffstat (limited to 'system/tls/init.go')
-rw-r--r-- | system/tls/init.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/system/tls/init.go b/system/tls/init.go index 5ffaf33..80e1ef3 100644 --- a/system/tls/init.go +++ b/system/tls/init.go @@ -19,7 +19,7 @@ var m autocert.Manager func setup() { pwd, err := os.Getwd() if err != nil { - log.Fatalln("Couldn't find working directory to locate or save certs.") + log.Fatalln("Couldn't find working directory to locate or save certificates.") } cache := autocert.DirCache(filepath.Join(pwd, "system", "tls", "certs")) @@ -30,13 +30,24 @@ func setup() { } } + // get host/domain and email from Config to use for TLS request to Let's encryption. + // we will fail fatally if either are not found since Let's Encrypt will rate-limit + // and sending incomplete requests is wasteful and guarenteed to fail its check host, err := db.Config("domain") if err != nil { + log.Fatalln("Error identifying host/domain during TLS set-up.", err) + } + + if host == nil { log.Fatalln("No 'domain' field set in Configuration. Please add a domain before attempting to make certificates.") } email, err := db.Config("admin_email") if err != nil { + log.Fatalln("Error identifying admin email during TLS set-up.", err) + } + + if email == nil { log.Fatalln("No 'admin_email' field set in Configuration. Please add an admin email before attempting to make certificates.") } |