{"action":"created","issue":{"url":"https://api.github.com/repos/docker/swarm/issues/212","labels_url":"https://api.github.com/repos/docker/swarm/issues/212/labels{/name}","comments_url":"https://api.github.com/repos/docker/swarm/issues/212/comments","events_url":"https://api.github.com/repos/docker/swarm/issues/212/events","html_url":"https://github.com/docker/swarm/issues/212","id":53167223,"number":212,"title":"proxy function doesn't configure TLSClientConfig","user":{"login":"karlhelgason","id":5183821,"avatar_url":"https://avatars.githubusercontent.com/u/5183821?v=3","gravatar_id":"","url":"https://api.github.com/users/karlhelgason","html_url":"https://github.com/karlhelgason","followers_url":"https://api.github.com/users/karlhelgason/followers","following_url":"https://api.github.com/users/karlhelgason/following{/other_user}","gists_url":"https://api.github.com/users/karlhelgason/gists{/gist_id}","starred_url":"https://api.github.com/users/karlhelgason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlhelgason/subscriptions","organizations_url":"https://api.github.com/users/karlhelgason/orgs","repos_url":"https://api.github.com/users/karlhelgason/repos","events_url":"https://api.github.com/users/karlhelgason/events{/privacy}","received_events_url":"https://api.github.com/users/karlhelgason/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-12-31T04:51:41Z","updated_at":"2015-01-06T00:34:18Z","closed_at":null,"body":"When using swarm with TLS I get the error: **\" x509: certificate signed by unknown authority \"** when using *\"docker start\"* and it also happens with *\"docker logs\"*.\r\n\r\nThe problem is that proxy function in utils.go doesn't use the tlsConfig.\r\n\r\nThis is what is missing is to configure the tls transport in the proxy function:\r\n\r\n`  httpTransport := &http.Transport{`\r\n`    TLSClientConfig: tlsConfig,`\r\n`  }`\r\n`  client := &http.Client{Transport: httpTransport}`\r\n\r\nAfter making these changes \"docker start\" worked correctly.\r\n\r\n## here is full-list of changes I made to get it work:\r\n\r\n**api/api.go**\r\n\r\nfirst I needed to relay cluster variable to proxy function\r\n\r\n        func proxyContainer(c *context, w http.ResponseWriter, r *http.Request) {\r\n            container, err := getContainerFromVars(c, mux.Vars(r))\r\n            if err != nil {\r\n                    httpError(w, err.Error(), http.StatusNotFound)\r\n                    return\r\n            }\r\n\r\n            if err := proxy(c.cluster, container, w, r); err != nil {\r\n                    httpError(w, err.Error(), http.StatusInternalServerError)\r\n            }\r\n        }\r\n\r\n**api/utils.go**\r\n \r\nfrom the cluster variable I read the TlsConfig\r\n\r\n     func proxy(c *cluster.Cluster, container *cluster.Container, w http.ResponseWriter, r *http.Request)   error {\r\n\r\n        httpTransport := &http.Transport{\r\n                TLSClientConfig: c.TlsConfig,\r\n        }\r\n\r\n        // Use a new client for each request\r\n        client := &http.Client{Transport: httpTransport}\r\n\r\n        // RequestURI may not be sent to client\r\n        r.RequestURI = \"\"\r\n\r\n        parts := strings.SplitN(container.Node().Addr, \"://\", 2)\r\n        if len(parts) == 2 {\r\n                r.URL.Scheme = parts[0]\r\n                r.URL.Host = parts[1]\r\n        } else {\r\n                r.URL.Scheme = \"http\"\r\n                r.URL.Host = parts[0]\r\n        }\r\n\r\n        log.Debugf(\"[PROXY] --> %s %s\", r.Method, r.URL)\r\n        resp, err := client.Do(r)\r\n        if err != nil {\r\n                return err\r\n        }\r\n        w.WriteHeader(resp.StatusCode)\r\n        io.Copy(w, resp.Body)\r\n\r\n        return nil\r\n    }\r\n\r\n**cluster/cluster.go**\r\n\r\nTlsConfig needed to be public for proxy function to be able to access it.\r\n\r\n\r\n        type Cluster struct {\r\n            sync.RWMutex\r\n            TlsConfig     *tls.Config\r\n            eventHandlers []EventHandler\r\n            nodes         map[string]*Node\r\n        }\r\n\r\n  ....\r\n\r\n      if err := n.Connect(c.TlsConfig); err != nil {\r\n"},"comment":{"url":"https://api.github.com/repos/docker/swarm/issues/comments/68807848","html_url":"https://github.com/docker/swarm/issues/212#issuecomment-68807848","issue_url":"https://api.github.com/repos/docker/swarm/issues/212","id":68807848,"user":{"login":"vieux","id":1032519,"avatar_url":"https://avatars.githubusercontent.com/u/1032519?v=3","gravatar_id":"","url":"https://api.github.com/users/vieux","html_url":"https://github.com/vieux","followers_url":"https://api.github.com/users/vieux/followers","following_url":"https://api.github.com/users/vieux/following{/other_user}","gists_url":"https://api.github.com/users/vieux/gists{/gist_id}","starred_url":"https://api.github.com/users/vieux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vieux/subscriptions","organizations_url":"https://api.github.com/users/vieux/orgs","repos_url":"https://api.github.com/users/vieux/repos","events_url":"https://api.github.com/users/vieux/events{/privacy}","received_events_url":"https://api.github.com/users/vieux/received_events","type":"User","site_admin":false},"created_at":"2015-01-06T00:34:18Z","updated_at":"2015-01-06T00:34:18Z","body":"@karlhelgason thank you! can you open a pull request ? with your changes ?"}}