tlsconfig: better format for error message in tlsconfig
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
9f198e9313
commit
1c73db81af
1 changed files with 4 additions and 4 deletions
|
@ -72,10 +72,10 @@ func certPool(caFile string) (*x509.CertPool, error) {
|
||||||
certPool := x509.NewCertPool()
|
certPool := x509.NewCertPool()
|
||||||
pem, err := ioutil.ReadFile(caFile)
|
pem, err := ioutil.ReadFile(caFile)
|
||||||
if err != nil {
|
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) {
|
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()
|
s := certPool.Subjects()
|
||||||
subjects := make([]string, len(s))
|
subjects := make([]string, len(s))
|
||||||
|
@ -116,9 +116,9 @@ func Server(options Options) (*tls.Config, error) {
|
||||||
tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile)
|
tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
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}
|
tlsConfig.Certificates = []tls.Certificate{tlsCert}
|
||||||
if options.ClientAuth >= tls.VerifyClientCertIfGiven {
|
if options.ClientAuth >= tls.VerifyClientCertIfGiven {
|
||||||
|
|
Loading…
Reference in a new issue