diff options
author | 2018-02-12 16:13:14 -0800 | |
---|---|---|
committer | 2018-02-12 16:18:54 -0800 | |
commit | bb1feb30c22bb3e23f633ee44eed9707b2d4a3b5 (patch) | |
tree | 5fd4aac507f0a19a636ff879b1775da8c002234c | |
parent | f11a02780f2210e9e734879afb1d45c89b8ed814 (diff) |
Auth.go returns error during tlsconfig
Auth package should return an error to the calling function
instead of erroring out with log.Fatal
Issue-ID: AAF-99
Change-Id: I9f1abd3710a85df85ac6e1d623dc16d77b977f1a
Signed-off-by: Kiran <kiran.k.kamineni@intel.com>
-rw-r--r-- | sms-service/src/sms/auth/auth.go | 8 | ||||
-rw-r--r-- | sms-service/src/sms/sms.go | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/sms-service/src/sms/auth/auth.go b/sms-service/src/sms/auth/auth.go index 690fe62..8186738 100644 --- a/sms-service/src/sms/auth/auth.go +++ b/sms-service/src/sms/auth/auth.go @@ -20,21 +20,19 @@ import ( "crypto/tls" "crypto/x509" "io/ioutil" - "log" ) var tlsConfig *tls.Config // GetTLSConfig initializes a tlsConfig using the CA's certificate // This config is then used to enable the server for mutual TLS -func GetTLSConfig(caCertFile string) *tls.Config { +func GetTLSConfig(caCertFile string) (*tls.Config, error) { // Initialize tlsConfig once if tlsConfig == nil { caCert, err := ioutil.ReadFile(caCertFile) if err != nil { - log.Fatal("Error reading CA Certificate") - log.Fatal(err) + return nil, err } caCertPool := x509.NewCertPool() @@ -47,5 +45,5 @@ func GetTLSConfig(caCertFile string) *tls.Config { } tlsConfig.BuildNameToCertificate() } - return tlsConfig + return tlsConfig, nil } diff --git a/sms-service/src/sms/sms.go b/sms-service/src/sms/sms.go index 98b2824..b117bbc 100644 --- a/sms-service/src/sms/sms.go +++ b/sms-service/src/sms/sms.go @@ -41,7 +41,10 @@ func main() { httpRouter := smshandler.CreateRouter(backendImpl) // TODO: Use CA certificate from AAF - tlsConfig := smsauth.GetTLSConfig(smsConf.CAFile) + tlsConfig, err := smsauth.GetTLSConfig(smsConf.CAFile) + if err != nil { + log.Fatal(err) + } httpServer := &http.Server{ Handler: httpRouter, |