Skip to content

Commit 40de743

Browse files
committed
Don't use TLS for socket connections
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 283d8f9 commit 40de743

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

cli/command/cli.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ func NewAPIClientFromFlags(opts *cliflags.CommonOptions, configFile *configfile.
284284
return &client.Client{}, err
285285
}
286286
if helper == nil {
287-
clientOpts = append(clientOpts, withHTTPClient(opts.TLSOptions))
287+
if !dopts.IsSocket(host) {
288+
clientOpts = append(clientOpts, withHTTPClient(opts.TLSOptions))
289+
}
288290
clientOpts = append(clientOpts, client.WithHost(host))
289291
} else {
290292
clientOpts = append(clientOpts, func(c *client.Client) error {

opts/hosts.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ func parseDockerDaemonHost(addr string) (string, error) {
8484
}
8585
}
8686

87+
// IsSocket checks if the given address is a Unix-socket (linux) or named pipe (Windows)
88+
func IsSocket(addr string) bool {
89+
addrParts := strings.SplitN(addr, "://", 2)
90+
if len(addrParts) == 1 && addrParts[0] != "" {
91+
addrParts = []string{"tcp", addrParts[0]}
92+
}
93+
switch addrParts[0] {
94+
case "unix", "npipe", "fd":
95+
return true
96+
}
97+
return false
98+
}
99+
87100
// parseSimpleProtoAddr parses and validates that the specified address is a valid
88101
// socket address for simple protocols like unix and npipe. It returns a formatted
89102
// socket address, either using the address parsed from addr, or the contents of

0 commit comments

Comments
 (0)