Allow to connect to docker daemons without certificates but using tls

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-15 17:19:34 -03:00
parent 6ac9784bef
commit e9e20a5e79
3 changed files with 11 additions and 5 deletions

View File

@@ -83,14 +83,16 @@ func (f *localCachedFactory) GetForInstance(instance *types.Instance) (DockerApi
// Need to create client to the DinD docker daemon
// We check if the client needs to use TLS
var tlsConfig *tls.Config
if len(instance.Cert) > 0 && len(instance.Key) > 0 {
if (len(instance.Cert) > 0 && len(instance.Key) > 0) || instance.Tls {
tlsConfig = tlsconfig.ClientDefault()
tlsConfig.InsecureSkipVerify = true
tlsCert, err := tls.X509KeyPair(instance.Cert, instance.Key)
if err != nil {
return nil, fmt.Errorf("Could not load X509 key pair: %v. Make sure the key is not encrypted", err)
if len(instance.Cert) > 0 && len(instance.Key) > 0 {
tlsCert, err := tls.X509KeyPair(instance.Cert, instance.Key)
if err != nil {
return nil, fmt.Errorf("Could not load X509 key pair: %v. Make sure the key is not encrypted", err)
}
tlsConfig.Certificates = []tls.Certificate{tlsCert}
}
tlsConfig.Certificates = []tls.Certificate{tlsCert}
}
proxyUrl, _ := url.Parse("http://l2:443")