diff --git a/client/client.go b/client/client.go index abb58907f..51f2f71f3 100644 --- a/client/client.go +++ b/client/client.go @@ -146,10 +146,6 @@ func newHttpsClient(conf Config) (*http.Client, error) { trustedcerts, err := loadServerTrust(conf) if err != nil { - log.Error("Can not open certificate file.") - log.Error("Your /etc/mender/server.crt can not be opened, if you are using " + - "self-signed certificates make sure to include the API Gateway and " + - "Storage Proxy certificates here.") return nil, errors.Wrapf(err, "cannot initialize server trust") } @@ -178,6 +174,8 @@ type Config struct { func loadServerTrust(conf Config) (*x509.CertPool, error) { if conf.ServerCert == "" { + // TODO: this is for pre-production version only to simplify tests. + // Make sure to remove in production version. log.Warn("Server certificate not provided. Trusting all servers.") return nil, nil } @@ -190,12 +188,13 @@ func loadServerTrust(conf Config) (*x509.CertPool, error) { // Read certificate file. servcert, err := ioutil.ReadFile(conf.ServerCert) if err != nil { - log.Error("/etc/mender/server.crt is inaccessible.") + log.Errorf("%s is inaccessible: %s", conf.ServerCert, err.Error()) return nil, err } if len(servcert) == 0 { - log.Error("/etc/mender/server.crt is empty.") + log.Errorf("Both %s and the system certificate pool are empty.", + conf.ServerCert) return nil, errors.New("server certificate is empty") } @@ -203,7 +202,6 @@ func loadServerTrust(conf Config) (*x509.CertPool, error) { if block != nil { cert, err := x509.ParseCertificate(block.Bytes) if err == nil { - log.Info("Have correct server certificate.") log.Infof("API Gateway certificate (in PEM format): \n%s", string(servcert)) log.Infof("Issuer: %s, Valid from: %s, Valid to: %s", cert.Issuer.Organization, cert.NotBefore, cert.NotAfter)