Windows: Fix certificate directory for registry

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2015-08-04 16:30:00 -07:00
parent cfb0b7aa77
commit 86a3ea91b8
7 changed files with 65 additions and 41 deletions

View file

@ -20,6 +20,26 @@ type Options struct {
InsecureRegistries opts.ListOpts 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 ( var (
// ErrInvalidRepositoryName is an error returned if the repository name did // ErrInvalidRepositoryName is an error returned if the repository name did
// not have the correct form // not have the correct form

19
docs/config_unix.go Normal file
View 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
View 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))
}

View file

@ -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/"
)

View file

@ -1,6 +0,0 @@
// +build !windows
package registry
// DefaultV2Registry is the URI of the default v2 registry
const DefaultV2Registry = "https://registry-1.docker.io"

View file

@ -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"

View file

@ -58,7 +58,7 @@ func newTLSConfig(hostname string, isSecure bool) (*tls.Config, error) {
tlsConfig.InsecureSkipVerify = !isSecure tlsConfig.InsecureSkipVerify = !isSecure
if isSecure { if isSecure {
hostDir := filepath.Join(CertsDir, hostname) hostDir := filepath.Join(CertsDir, cleanPath(hostname))
logrus.Debugf("hostDir: %s", hostDir) logrus.Debugf("hostDir: %s", hostDir)
if err := ReadCertsDirectory(&tlsConfig, hostDir); err != nil { if err := ReadCertsDirectory(&tlsConfig, hostDir); err != nil {
return nil, err return nil, err