File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,6 +337,9 @@ func (c *criService) registryHosts(auth *runtime.AuthConfig) docker.RegistryHost
337337 if err != nil {
338338 return nil , errors .Wrapf (err , "get TLSConfig for registry %q" , e )
339339 }
340+ } else if isLocalHost (host ) && u .Scheme == "http" {
341+ // Skipping TLS verification for localhost
342+ transport .TLSClientConfig .InsecureSkipVerify = true
340343 }
341344
342345 if auth == nil && config .Auth != nil {
@@ -366,13 +369,24 @@ func (c *criService) registryHosts(auth *runtime.AuthConfig) docker.RegistryHost
366369
367370// defaultScheme returns the default scheme for a registry host.
368371func defaultScheme (host string ) string {
372+ if isLocalHost (host ) {
373+ return "http"
374+ }
375+ return "https"
376+ }
377+
378+ // isLocalHost checks if the registry host is local.
379+ func isLocalHost (host string ) bool {
369380 if h , _ , err := net .SplitHostPort (host ); err == nil {
370381 host = h
371382 }
372- if host == "localhost" || host == "127.0.0.1" || host == "::1" {
373- return "http"
383+
384+ if host == "localhost" {
385+ return true
374386 }
375- return "https"
387+
388+ ip := net .ParseIP (host )
389+ return ip .IsLoopback ()
376390}
377391
378392// addDefaultScheme returns the endpoint with default scheme
You can’t perform that action at this time.
0 commit comments