summaryrefslogtreecommitdiff
path: root/client/transport.go
diff options
context:
space:
mode:
authorStephen J Day <stephen.day@docker.com>2016-09-21 19:16:44 -0700
committerStephen J Day <stephen.day@docker.com>2016-09-27 16:27:48 -0700
commitdc9f5c2ca3cdf8fef5786a80a0a1b0e7c18d4420 (patch)
tree3b1bcf52555a510c16cec8b9d1f5aec7eaf36774 /client/transport.go
parentc5f4a1ab1947d4c9084e1849db77594886b8fe95 (diff)
downloaddocker-dc9f5c2ca3cdf8fef5786a80a0a1b0e7c18d4420.tar.gz
client: pedantic checking of tlsconfig
Under the convoluted code path for the transport configuration, TLSConfig was being set even though the socket type is unix. This caused other code detecting the TLSConfig to assume https, rather than using the http scheme. This led to a situation where if `DOCKER_CERT_PATH` is set, unix sockets start reverting to https. There is other odd behavior from go-connections that is also reproduced here. For the most part, we try to reproduce the side-effecting behavior from go-connections to retain the current docker behavior. This whole mess needs to ripped out and fixed, as this pile spaghetti is unnacceptable. This code is way to convoluted for an http client. We'll need to fix this but the Go API will break to do it. Signed-off-by: Stephen J Day <stephen.day@docker.com>
Diffstat (limited to 'client/transport.go')
-rw-r--r--client/transport.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/client/transport.go b/client/transport.go
index 43a667272d..771d76f06b 100644
--- a/client/transport.go
+++ b/client/transport.go
@@ -18,14 +18,12 @@ func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) {
// resolveTLSConfig attempts to resolve the tls configuration from the
// RoundTripper.
-func resolveTLSConfig(transport http.RoundTripper) (*tls.Config, error) {
+func resolveTLSConfig(transport http.RoundTripper) *tls.Config {
switch tr := transport.(type) {
case *http.Transport:
- return tr.TLSClientConfig, nil
- case transportFunc:
- return nil, nil // detect this type for testing.
+ return tr.TLSClientConfig
default:
- return nil, errTLSConfigUnavailable
+ return nil
}
}
@@ -37,15 +35,11 @@ func resolveTLSConfig(transport http.RoundTripper) (*tls.Config, error) {
// Unfortunately, the model of having a host-ish/url-thingy as the connection
// string has us confusing protocol and transport layers. We continue doing
// this to avoid breaking existing clients but this should be addressed.
-func resolveScheme(transport http.RoundTripper) (string, error) {
- c, err := resolveTLSConfig(transport)
- if err != nil {
- return "", err
- }
-
+func resolveScheme(transport http.RoundTripper) string {
+ c := resolveTLSConfig(transport)
if c != nil {
- return "https", nil
+ return "https"
}
- return "http", nil
+ return "http"
}