diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-10-03 21:33:44 -0700 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-10-06 19:29:25 -0500 |
commit | 294020406c257ad4eb1867a1e7fb8b694aefddd2 (patch) | |
tree | 3a5eeb5e8566584d2098b6ac7772d6653cc38acf /cmd/cashierd | |
parent | 3c99b9496d04fe389b4b7779fe24fb0927f0347b (diff) |
Use wkfs when loading tls certs
Diffstat (limited to 'cmd/cashierd')
-rw-r--r-- | cmd/cashierd/main.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/cmd/cashierd/main.go b/cmd/cashierd/main.go index 88f190e..563f4fd 100644 --- a/cmd/cashierd/main.go +++ b/cmd/cashierd/main.go @@ -17,6 +17,7 @@ import ( "strconv" "strings" + "go4.org/wkfs" "golang.org/x/oauth2" "github.com/gorilla/csrf" @@ -312,6 +313,18 @@ func certStore(config string) (store.CertStorer, error) { return cstore, err } +func loadCerts(certFile, keyFile string) (tls.Certificate, error) { + key, err := wkfs.ReadFile(keyFile) + if err != nil { + return tls.Certificate{}, err + } + cert, err := wkfs.ReadFile(certFile) + if err != nil { + return tls.Certificate{}, err + } + return tls.X509KeyPair(cert, key) +} + func main() { // Privileged section flag.Parse() @@ -343,7 +356,7 @@ func main() { tlsConfig := &tls.Config{} if config.Server.UseTLS { tlsConfig.Certificates = make([]tls.Certificate, 1) - tlsConfig.Certificates[0], err = tls.LoadX509KeyPair(config.Server.TLSCert, config.Server.TLSKey) + tlsConfig.Certificates[0], err = loadCerts(config.Server.TLSCert, config.Server.TLSKey) if err != nil { log.Fatal(err) } |