* control: TLS: don't return empty error messages

This commit is contained in:
Simon Zolin 2019-02-28 11:55:16 +03:00
parent 241e7ca20c
commit 224c2a891d
1 changed files with 4 additions and 4 deletions

View File

@ -138,14 +138,14 @@ func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string)
parsed, err := x509.ParseCertificate(cert.Bytes) parsed, err := x509.ParseCertificate(cert.Bytes)
if err != nil { if err != nil {
data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err)
return errors.New("") return errors.New(data.WarningValidation)
} }
parsedCerts = append(parsedCerts, parsed) parsedCerts = append(parsedCerts, parsed)
} }
if len(parsedCerts) == 0 { if len(parsedCerts) == 0 {
data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") data.WarningValidation = fmt.Sprintf("You have specified an empty certificate")
return errors.New("") return errors.New(data.WarningValidation)
} }
data.ValidCert = true data.ValidCert = true
@ -214,14 +214,14 @@ func validatePkey(data *tlsConfigStatus, pkey string) error {
if key == nil { if key == nil {
data.WarningValidation = "No valid keys were found" data.WarningValidation = "No valid keys were found"
return errors.New("") return errors.New(data.WarningValidation)
} }
// parse the decoded key // parse the decoded key
_, keytype, err := parsePrivateKey(key.Bytes) _, keytype, err := parsePrivateKey(key.Bytes)
if err != nil { if err != nil {
data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err)
return errors.New("") return errors.New(data.WarningValidation)
} }
data.ValidKey = true data.ValidKey = true