diff --git a/cmd/certs.go b/cmd/certs.go index a7378f20b..54b821824 100644 --- a/cmd/certs.go +++ b/cmd/certs.go @@ -150,24 +150,20 @@ func loadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) { return cert, nil } -func getSSLConfig() (x509Certs []*x509.Certificate, rootCAs *x509.CertPool, c *certs.Certs, secureConn bool, err error) { +func getTLSConfig() (x509Certs []*x509.Certificate, c *certs.Certs, secureConn bool, err error) { if !(isFile(getPublicCertFile()) && isFile(getPrivateKeyFile())) { - return nil, nil, nil, false, nil + return nil, nil, false, nil } if x509Certs, err = parsePublicCertFile(getPublicCertFile()); err != nil { - return nil, nil, nil, false, err + return nil, nil, false, err } c, err = certs.New(getPublicCertFile(), getPrivateKeyFile(), loadX509KeyPair) if err != nil { - return nil, nil, nil, false, err - } - - if rootCAs, err = getRootCAs(getCADir()); err != nil { - return nil, nil, nil, false, err + return nil, nil, false, err } secureConn = true - return x509Certs, rootCAs, c, secureConn, nil + return x509Certs, c, secureConn, nil } diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index b7336a5e3..bdcca38b7 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -157,10 +157,14 @@ func StartGateway(ctx *cli.Context, gw Gateway) { // Create certs path. logger.FatalIf(createConfigDir(), "Unable to create configuration directories") - // Check and load SSL certificates. + // Check and load TLS certificates. var err error - globalPublicCerts, globalRootCAs, globalTLSCerts, globalIsSSL, err = getSSLConfig() - logger.FatalIf(err, "Invalid SSL certificate file") + globalPublicCerts, globalTLSCerts, globalIsSSL, err = getTLSConfig() + logger.FatalIf(err, "Invalid TLS certificate file") + + // Check and load Root CAs. + globalRootCAs, err = getRootCAs(getCADir()) + logger.FatalIf(err, "Failed to read root CAs (%v)", err) // Set system resources to maximum. logger.LogIf(context.Background(), setMaxResources()) diff --git a/cmd/server-main.go b/cmd/server-main.go index 5309e523f..bbdaa2315 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -227,11 +227,15 @@ func serverMain(ctx *cli.Context) { // Create certs path. logger.FatalIf(createConfigDir(), "Unable to initialize configuration files") - // Check and load SSL certificates. + // Check and load TLS certificates. var err error - globalPublicCerts, globalRootCAs, globalTLSCerts, globalIsSSL, err = getSSLConfig() + globalPublicCerts, globalTLSCerts, globalIsSSL, err = getTLSConfig() logger.FatalIf(err, "Unable to load the TLS configuration") + // Check and load Root CAs. + globalRootCAs, err = getRootCAs(getCADir()) + logger.FatalIf(err, "Failed to read root CAs (%v)", err) + // Is distributed setup, error out if no certificates are found for HTTPS endpoints. if globalIsDistXL { if globalEndpoints.IsHTTPS() && !globalIsSSL {