From c7a04fda2ad804601385f054c19b69cf43fcfe46 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Thu, 30 Jul 2015 14:15:41 -0400 Subject: [PATCH] tlsconfig: better format for error message in tlsconfig Signed-off-by: Tibor Vass --- docker/daemon.go | 2 +- pkg/tlsconfig/config.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/daemon.go b/docker/daemon.go index aa2bd54a33..0e1fc8224a 100644 --- a/docker/daemon.go +++ b/docker/daemon.go @@ -228,7 +228,7 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error { } tlsConfig, err := tlsconfig.Server(*commonFlags.TLSOptions) if err != nil { - logrus.Fatalf("foobar: %v", err) + logrus.Fatal(err) } serverConfig.TLSConfig = tlsConfig } diff --git a/pkg/tlsconfig/config.go b/pkg/tlsconfig/config.go index 88f768ae24..9f7f336947 100644 --- a/pkg/tlsconfig/config.go +++ b/pkg/tlsconfig/config.go @@ -72,10 +72,10 @@ func certPool(caFile string) (*x509.CertPool, error) { certPool := x509.NewCertPool() pem, err := ioutil.ReadFile(caFile) if err != nil { - return nil, fmt.Errorf("Could not read CA certificate %s: %v", caFile, err) + return nil, fmt.Errorf("Could not read CA certificate %q: %v", caFile, err) } if !certPool.AppendCertsFromPEM(pem) { - return nil, fmt.Errorf("failed to append certificates from PEM file: %s", caFile) + return nil, fmt.Errorf("failed to append certificates from PEM file: %q", caFile) } s := certPool.Subjects() subjects := make([]string, len(s)) @@ -116,9 +116,9 @@ func Server(options Options) (*tls.Config, error) { tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile) if err != nil { if os.IsNotExist(err) { - return nil, fmt.Errorf("Could not load X509 key pair (%s, %s): %v", options.CertFile, options.KeyFile, err) + return nil, fmt.Errorf("Could not load X509 key pair (cert: %q, key: %q): %v", options.CertFile, options.KeyFile, err) } - return nil, fmt.Errorf("Error reading X509 key pair (%s, %s): %v. Make sure the key is not encrypted.", options.CertFile, options.KeyFile, err) + return nil, fmt.Errorf("Error reading X509 key pair (cert: %q, key: %q): %v. Make sure the key is not encrypted.", options.CertFile, options.KeyFile, err) } tlsConfig.Certificates = []tls.Certificate{tlsCert} if options.ClientAuth >= tls.VerifyClientCertIfGiven {