mirror of https://github.com/docker/docs.git
Use tls client config utility in notary as well.
Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
fb1013b997
commit
fc389b7bc3
|
@ -3,8 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/tls"
|
|
||||||
"crypto/x509"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
@ -22,7 +20,7 @@ import (
|
||||||
"github.com/docker/distribution/registry/client/transport"
|
"github.com/docker/distribution/registry/client/transport"
|
||||||
"github.com/docker/docker/pkg/term"
|
"github.com/docker/docker/pkg/term"
|
||||||
notaryclient "github.com/docker/notary/client"
|
notaryclient "github.com/docker/notary/client"
|
||||||
"github.com/docker/notary/trustmanager"
|
"github.com/docker/notary/utils"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -360,7 +358,6 @@ func (ps passwordStore) Basic(u *url.URL) (string, string) {
|
||||||
|
|
||||||
func getTransport(gun string, readOnly bool) http.RoundTripper {
|
func getTransport(gun string, readOnly bool) http.RoundTripper {
|
||||||
// Attempt to get a root CA from the config file. Nil is the host defaults.
|
// Attempt to get a root CA from the config file. Nil is the host defaults.
|
||||||
rootPool := x509.NewCertPool()
|
|
||||||
rootCAFile := mainViper.GetString("remote_server.root_ca")
|
rootCAFile := mainViper.GetString("remote_server.root_ca")
|
||||||
if rootCAFile != "" {
|
if rootCAFile != "" {
|
||||||
// If we haven't been given an Absolute path, we assume it's relative
|
// If we haven't been given an Absolute path, we assume it's relative
|
||||||
|
@ -368,19 +365,13 @@ func getTransport(gun string, readOnly bool) http.RoundTripper {
|
||||||
if !filepath.IsAbs(rootCAFile) {
|
if !filepath.IsAbs(rootCAFile) {
|
||||||
rootCAFile = filepath.Join(configPath, rootCAFile)
|
rootCAFile = filepath.Join(configPath, rootCAFile)
|
||||||
}
|
}
|
||||||
rootCert, err := trustmanager.LoadCertFromFile(rootCAFile)
|
|
||||||
if err != nil {
|
|
||||||
fatalf("could not load root ca file. %s", err.Error())
|
|
||||||
}
|
|
||||||
rootPool.AddCert(rootCert)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// skipTLSVerify is false by default so verification will
|
tlsConfig, err := utils.ConfigureClientTLS(
|
||||||
// be performed.
|
rootCAFile, "", mainViper.GetBool("remote_server.skipTLSVerify"),
|
||||||
tlsConfig := &tls.Config{
|
"", "")
|
||||||
InsecureSkipVerify: mainViper.GetBool("remote_server.skipTLSVerify"),
|
if err != nil {
|
||||||
MinVersion: tls.VersionTLS10,
|
logrus.Fatal("Unable to configure TLS: ", err.Error())
|
||||||
RootCAs: rootPool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base := &http.Transport{
|
base := &http.Transport{
|
||||||
|
|
Loading…
Reference in New Issue