Skip to content

Commit e8e6ac5

Browse files
authored
Fix/missing ssl params (helm#3152)
* fix(helm): add TLS params back During a recent refactor, several TLS flags stopped being processed for a few of the commands. This fixes those commands, and documents how to set up TLS. * fix(tiller): add stricter certificate verification The older version of Tiller allowed a weaker set of certificate checks than we intended. This version requires a client certificate, and then requires that that certificate be signed by a known CA. This works around the situation where a user could provide a self-signed certificate.
1 parent 4167c56 commit e8e6ac5

File tree

12 files changed

+342
-22
lines changed

12 files changed

+342
-22
lines changed

cmd/helm/get.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
6464
}
6565
get.release = args[0]
6666
if get.client == nil {
67-
get.client = helm.NewClient(helm.Host(settings.TillerHost))
67+
get.client = newClient()
6868
}
6969
return get.run()
7070
},
7171
}
7272

7373
cmd.Flags().Int32Var(&get.version, "revision", 0, "get the named release with revision")
7474

75-
cmd.AddCommand(newGetValuesCmd(nil, out))
76-
cmd.AddCommand(newGetManifestCmd(nil, out))
77-
cmd.AddCommand(newGetHooksCmd(nil, out))
75+
cmd.AddCommand(addFlagsTLS(newGetValuesCmd(nil, out)))
76+
cmd.AddCommand(addFlagsTLS(newGetManifestCmd(nil, out)))
77+
cmd.AddCommand(addFlagsTLS(newGetHooksCmd(nil, out)))
7878

7979
return cmd
8080
}

cmd/helm/helm.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ var (
4545
tlsVerify bool // enable TLS and verify remote certificates
4646
tlsEnable bool // enable TLS
4747

48+
tlsCaCertDefault = "$HELM_HOME/ca.pem"
49+
tlsCertDefault = "$HELM_HOME/cert.pem"
50+
tlsKeyDefault = "$HELM_HOME/key.pem"
51+
4852
tillerTunnel *kube.Tunnel
4953
settings helm_env.EnvSettings
5054
)
@@ -263,6 +267,16 @@ func newClient() helm.Interface {
263267
options := []helm.Option{helm.Host(settings.TillerHost)}
264268

265269
if tlsVerify || tlsEnable {
270+
if tlsCaCertFile == "" {
271+
tlsCaCertFile = os.ExpandEnv(tlsCaCertDefault)
272+
}
273+
if tlsCertFile == "" {
274+
tlsCertFile = os.ExpandEnv(tlsCertDefault)
275+
}
276+
if tlsKeyFile == "" {
277+
tlsKeyFile = os.ExpandEnv(tlsKeyDefault)
278+
}
279+
debug("Key=%q, Cert=%q, CA=%q\n", tlsKeyFile, tlsCertFile, tlsCaCertFile)
266280
tlsopts := tlsutil.Options{KeyFile: tlsKeyFile, CertFile: tlsCertFile, InsecureSkipVerify: true}
267281
if tlsVerify {
268282
tlsopts.CaCertFile = tlsCaCertFile
@@ -281,12 +295,6 @@ func newClient() helm.Interface {
281295
// addFlagsTLS adds the flags for supporting client side TLS to the
282296
// helm command (only those that invoke communicate to Tiller.)
283297
func addFlagsTLS(cmd *cobra.Command) *cobra.Command {
284-
// defaults
285-
var (
286-
tlsCaCertDefault = "$HELM_HOME/ca.pem"
287-
tlsCertDefault = "$HELM_HOME/cert.pem"
288-
tlsKeyDefault = "$HELM_HOME/key.pem"
289-
)
290298

291299
// add flags
292300
cmd.Flags().StringVar(&tlsCaCertFile, "tls-ca-cert", tlsCaCertDefault, "path to TLS CA certificate file")

cmd/helm/history.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func newHistoryCmd(c helm.Interface, w io.Writer) *cobra.Command {
6666
case len(args) == 0:
6767
return errReleaseRequired
6868
case his.helmc == nil:
69-
his.helmc = helm.NewClient(helm.Host(settings.TillerHost))
69+
his.helmc = newClient()
7070
}
7171
his.rls = args[0]
7272
return his.run()

cmd/helm/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
9393
list.filter = strings.Join(args, " ")
9494
}
9595
if list.client == nil {
96-
list.client = helm.NewClient(helm.Host(settings.TillerHost))
96+
list.client = newClient()
9797
}
9898
return list.run()
9999
},

cmd/helm/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
6767
}
6868
status.release = args[0]
6969
if status.client == nil {
70-
status.client = helm.NewClient(helm.Host(settings.TillerHost))
70+
status.client = newClient()
7171
}
7272
return status.run()
7373
},

cmd/tiller/tiller.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ func tlsOptions() tlsutil.Options {
232232
opts := tlsutil.Options{CertFile: *certFile, KeyFile: *keyFile}
233233
if *tlsVerify {
234234
opts.CaCertFile = *caCertFile
235-
opts.ClientAuth = tls.VerifyClientCertIfGiven
235+
236+
// We want to force the client to not only provide a cert, but to
237+
// provide a cert that we can validate.
238+
// http://www.bite-code.com/2015/06/25/tls-mutual-auth-in-golang/
239+
opts.ClientAuth = tls.RequireAndVerifyClientCert
236240
}
237241
return opts
238242
}

docs/helm/helm_get_hooks.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ helm get hooks [flags] RELEASE_NAME
1818
### Options
1919

2020
```
21-
--revision int32 get the named release with revision
21+
--revision int32 get the named release with revision
22+
--tls enable TLS for request
23+
--tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem")
24+
--tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem")
25+
--tls-key string path to TLS key file (default "$HELM_HOME/key.pem")
26+
--tls-verify enable TLS for request and verify remote
2227
```
2328

2429
### Options inherited from parent commands
@@ -35,4 +40,4 @@ helm get hooks [flags] RELEASE_NAME
3540
### SEE ALSO
3641
* [helm get](helm_get.md) - download a named release
3742

38-
###### Auto generated by spf13/cobra on 7-Nov-2017
43+
###### Auto generated by spf13/cobra on 15-Nov-2017

docs/helm/helm_get_manifest.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ helm get manifest [flags] RELEASE_NAME
2020
### Options
2121

2222
```
23-
--revision int32 get the named release with revision
23+
--revision int32 get the named release with revision
24+
--tls enable TLS for request
25+
--tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem")
26+
--tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem")
27+
--tls-key string path to TLS key file (default "$HELM_HOME/key.pem")
28+
--tls-verify enable TLS for request and verify remote
2429
```
2530

2631
### Options inherited from parent commands
@@ -37,4 +42,4 @@ helm get manifest [flags] RELEASE_NAME
3742
### SEE ALSO
3843
* [helm get](helm_get.md) - download a named release
3944

40-
###### Auto generated by spf13/cobra on 7-Nov-2017
45+
###### Auto generated by spf13/cobra on 15-Nov-2017

docs/helm/helm_get_values.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ helm get values [flags] RELEASE_NAME
1616
### Options
1717

1818
```
19-
-a, --all dump all (computed) values
20-
--revision int32 get the named release with revision
19+
-a, --all dump all (computed) values
20+
--revision int32 get the named release with revision
21+
--tls enable TLS for request
22+
--tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem")
23+
--tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem")
24+
--tls-key string path to TLS key file (default "$HELM_HOME/key.pem")
25+
--tls-verify enable TLS for request and verify remote
2126
```
2227

2328
### Options inherited from parent commands
@@ -34,4 +39,4 @@ helm get values [flags] RELEASE_NAME
3439
### SEE ALSO
3540
* [helm get](helm_get.md) - download a named release
3641

37-
###### Auto generated by spf13/cobra on 7-Nov-2017
42+
###### Auto generated by spf13/cobra on 15-Nov-2017

docs/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- [Frequently Asked Questions](install_faq.md)
77
- [Using Helm](using_helm.md) - Learn the Helm tools
88
- [Plugins](plugins.md)
9+
- [Service Accounts for Tiller](service_accounts.md) - Apply RBACs to Tiller
10+
- [TLS/SSL for Helm and Tiller](tiller_ssl.md) - Use Helm-to-Tiller encryption
911
- [Developing Charts](charts.md) - An introduction to chart development
1012
- [Chart Lifecycle Hooks](charts_hooks.md)
1113
- [Chart Tips and Tricks](charts_tips_and_tricks.md)

0 commit comments

Comments
 (0)