Windows: Fix certificate directory for registry
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
cfb0b7aa77
commit
86a3ea91b8
7 changed files with 65 additions and 41 deletions
|
@ -20,6 +20,26 @@ type Options struct {
|
|||
InsecureRegistries opts.ListOpts
|
||||
}
|
||||
|
||||
const (
|
||||
// DefaultNamespace is the default namespace
|
||||
DefaultNamespace = "docker.io"
|
||||
// DefaultRegistryVersionHeader is the name of the default HTTP header
|
||||
// that carries Registry version info
|
||||
DefaultRegistryVersionHeader = "Docker-Distribution-Api-Version"
|
||||
// DefaultV1Registry is the URI of the default v1 registry
|
||||
DefaultV1Registry = "https://index.docker.io"
|
||||
|
||||
// IndexServer is the v1 registry server used for user auth + account creation
|
||||
IndexServer = DefaultV1Registry + "/v1/"
|
||||
// IndexName is the name of the index
|
||||
IndexName = "docker.io"
|
||||
|
||||
// NotaryServer is the endpoint serving the Notary trust server
|
||||
NotaryServer = "https://notary.docker.io"
|
||||
|
||||
// IndexServer = "https://registry-stage.hub.docker.com/v1/"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidRepositoryName is an error returned if the repository name did
|
||||
// not have the correct form
|
||||
|
|
19
docs/config_unix.go
Normal file
19
docs/config_unix.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
// +build !windows
|
||||
|
||||
package registry
|
||||
|
||||
const (
|
||||
// DefaultV2Registry is the URI of the default v2 registry
|
||||
DefaultV2Registry = "https://registry-1.docker.io"
|
||||
|
||||
// CertsDir is the directory where certificates are stored
|
||||
CertsDir = "/etc/docker/certs.d"
|
||||
)
|
||||
|
||||
// cleanPath is used to ensure that a directory name is valid on the target
|
||||
// platform. It will be passed in something *similar* to a URL such as
|
||||
// https:/index.docker.io/v1. Not all platforms support directory names
|
||||
// which contain those characters (such as : on Windows)
|
||||
func cleanPath(s string) string {
|
||||
return s
|
||||
}
|
25
docs/config_windows.go
Normal file
25
docs/config_windows.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package registry
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DefaultV2Registry is the URI of the default (official) v2 registry.
|
||||
// This is the windows-specific endpoint.
|
||||
//
|
||||
// Currently it is a TEMPORARY link that allows Microsoft to continue
|
||||
// development of Docker Engine for Windows.
|
||||
const DefaultV2Registry = "https://ms-tp3.registry-1.docker.io"
|
||||
|
||||
// CertsDir is the directory where certificates are stored
|
||||
var CertsDir = os.Getenv("programdata") + `\docker\certs.d`
|
||||
|
||||
// cleanPath is used to ensure that a directory name is valid on the target
|
||||
// platform. It will be passed in something *similar* to a URL such as
|
||||
// https:\index.docker.io\v1. Not all platforms support directory names
|
||||
// which contain those characters (such as : on Windows)
|
||||
func cleanPath(s string) string {
|
||||
return filepath.FromSlash(strings.Replace(s, ":", "", -1))
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package registry
|
||||
|
||||
const (
|
||||
// DefaultNamespace is the default namespace
|
||||
DefaultNamespace = "docker.io"
|
||||
// DefaultRegistryVersionHeader is the name of the default HTTP header
|
||||
// that carries Registry version info
|
||||
DefaultRegistryVersionHeader = "Docker-Distribution-Api-Version"
|
||||
// DefaultV1Registry is the URI of the default v1 registry
|
||||
DefaultV1Registry = "https://index.docker.io"
|
||||
|
||||
// CertsDir is the directory where certificates are stored
|
||||
CertsDir = "/etc/docker/certs.d"
|
||||
|
||||
// IndexServer is the v1 registry server used for user auth + account creation
|
||||
IndexServer = DefaultV1Registry + "/v1/"
|
||||
// IndexName is the name of the index
|
||||
IndexName = "docker.io"
|
||||
|
||||
// NotaryServer is the endpoint serving the Notary trust server
|
||||
NotaryServer = "https://notary.docker.io"
|
||||
|
||||
// IndexServer = "https://registry-stage.hub.docker.com/v1/"
|
||||
)
|
|
@ -1,6 +0,0 @@
|
|||
// +build !windows
|
||||
|
||||
package registry
|
||||
|
||||
// DefaultV2Registry is the URI of the default v2 registry
|
||||
const DefaultV2Registry = "https://registry-1.docker.io"
|
|
@ -1,10 +0,0 @@
|
|||
// +build windows
|
||||
|
||||
package registry
|
||||
|
||||
// DefaultV2Registry is the URI of the default (official) v2 registry.
|
||||
// This is the windows-specific endpoint.
|
||||
//
|
||||
// Currently it is a TEMPORARY link that allows Microsoft to continue
|
||||
// development of Docker Engine for Windows.
|
||||
const DefaultV2Registry = "https://ms-tp3.registry-1.docker.io"
|
|
@ -58,7 +58,7 @@ func newTLSConfig(hostname string, isSecure bool) (*tls.Config, error) {
|
|||
tlsConfig.InsecureSkipVerify = !isSecure
|
||||
|
||||
if isSecure {
|
||||
hostDir := filepath.Join(CertsDir, hostname)
|
||||
hostDir := filepath.Join(CertsDir, cleanPath(hostname))
|
||||
logrus.Debugf("hostDir: %s", hostDir)
|
||||
if err := ReadCertsDirectory(&tlsConfig, hostDir); err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue