mirror of https://github.com/portainer/portainer
fix(tls): fix an issue with TLSConfig ignored when using LDAP StartTLS
parent
1bccd521f8
commit
3fb668474d
|
@ -12,30 +12,28 @@ import (
|
||||||
func CreateTLSConfiguration(config *portainer.TLSConfiguration) (*tls.Config, error) {
|
func CreateTLSConfiguration(config *portainer.TLSConfiguration) (*tls.Config, error) {
|
||||||
TLSConfig := &tls.Config{}
|
TLSConfig := &tls.Config{}
|
||||||
|
|
||||||
if config.TLS {
|
if config.TLSCertPath != "" && config.TLSKeyPath != "" {
|
||||||
if config.TLSCertPath != "" && config.TLSKeyPath != "" {
|
cert, err := tls.LoadX509KeyPair(config.TLSCertPath, config.TLSKeyPath)
|
||||||
cert, err := tls.LoadX509KeyPair(config.TLSCertPath, config.TLSKeyPath)
|
if err != nil {
|
||||||
if err != nil {
|
return nil, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
TLSConfig.Certificates = []tls.Certificate{cert}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !config.TLSSkipVerify {
|
TLSConfig.Certificates = []tls.Certificate{cert}
|
||||||
caCert, err := ioutil.ReadFile(config.TLSCACertPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
caCertPool := x509.NewCertPool()
|
|
||||||
caCertPool.AppendCertsFromPEM(caCert)
|
|
||||||
|
|
||||||
TLSConfig.RootCAs = caCertPool
|
|
||||||
}
|
|
||||||
|
|
||||||
TLSConfig.InsecureSkipVerify = config.TLSSkipVerify
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !config.TLSSkipVerify {
|
||||||
|
caCert, err := ioutil.ReadFile(config.TLSCACertPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
caCertPool := x509.NewCertPool()
|
||||||
|
caCertPool.AppendCertsFromPEM(caCert)
|
||||||
|
|
||||||
|
TLSConfig.RootCAs = caCertPool
|
||||||
|
}
|
||||||
|
|
||||||
|
TLSConfig.InsecureSkipVerify = config.TLSSkipVerify
|
||||||
|
|
||||||
return TLSConfig, nil
|
return TLSConfig, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue