@ -12,30 +12,28 @@ import (
func CreateTLSConfiguration ( config * portainer . TLSConfiguration ) ( * tls . Config , error ) {
TLSConfig := & tls . Config { }
if config . TLS {
if config . TLSCertPath != "" && config . TLSKeyPath != "" {
cert , err := tls . LoadX509KeyPair ( config . TLSCertPath , config . TLSKeyPath )
if err != nil {
return nil , err
}
TLSConfig . Certificates = [ ] tls . Certificate { cert }
if config . TLSCertPath != "" && config . TLSKeyPath != "" {
cert , err := tls . LoadX509KeyPair ( config . TLSCertPath , config . TLSKeyPath )
if err != nil {
return nil , err
}
if ! config . TLSSkipVerify {
caCert , err := ioutil . ReadFile ( config . TLSCACertPath )
if err != nil {
return nil , err
}
caCertPool := x509 . NewCertPool ( )
caCertPool . AppendCertsFromPEM ( caCert )
TLSConfig . Certificates = [ ] tls . Certificate { cert }
}
TLSConfig . RootCAs = caCertPool
if ! config . TLSSkipVerify {
caCert , err := ioutil . ReadFile ( config . TLSCACertPath )
if err != nil {
return nil , err
}
TLSConfig . InsecureSkipVerify = config . TLSSkipVerify
caCertPool := x509 . NewCertPool ( )
caCertPool . AppendCertsFromPEM ( caCert )
TLSConfig . RootCAs = caCertPool
}
TLSConfig . InsecureSkipVerify = config . TLSSkipVerify
return TLSConfig , nil
}