Skip to content

Commit fe1d2b4

Browse files
committed
Allow specifying haproxy SSL Cipher list
The user can select from among 3 predefined cipher lists: modern, intermediate, or old. Alternatively the use may provide a custom cipher list see "man 1 ciphers". The list is used to negotiate a cipher between a user and haproxyi during bind. The predefined lists are from: https://wiki.mozilla.org/Security/Server_Side_TLS A new option to "oc adm router", --ciphers, is added to specify the cipher list. The values are modern|intermediate|old, or a ":" separated list of ciphers from "man 1 ciphers" Option --ciphers creates an environmen variable, ROUTER_CIPHERS, which is passed to the router pod. See https://trello.com/c/oeP7vrTZ
1 parent f5dc9cc commit fe1d2b4

File tree

11 files changed

+53
-4
lines changed

11 files changed

+53
-4
lines changed

contrib/completions/bash/oadm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,8 @@ _oadm_router()
47394739
flags_with_completion=()
47404740
flags_completion=()
47414741

4742+
flags+=("--ciphers=")
4743+
local_nonpersistent_flags+=("--ciphers=")
47424744
flags+=("--create")
47434745
local_nonpersistent_flags+=("--create")
47444746
flags+=("--default-cert=")

contrib/completions/bash/oc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4742,6 +4742,8 @@ _oc_adm_router()
47424742
flags_with_completion=()
47434743
flags_completion=()
47444744

4745+
flags+=("--ciphers=")
4746+
local_nonpersistent_flags+=("--ciphers=")
47454747
flags+=("--create")
47464748
local_nonpersistent_flags+=("--create")
47474749
flags+=("--default-cert=")

contrib/completions/bash/openshift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,8 @@ _openshift_admin_router()
47394739
flags_with_completion=()
47404740
flags_completion=()
47414741

4742+
flags+=("--ciphers=")
4743+
local_nonpersistent_flags+=("--ciphers=")
47424744
flags+=("--create")
47434745
local_nonpersistent_flags+=("--create")
47444746
flags+=("--default-cert=")
@@ -9870,6 +9872,8 @@ _openshift_cli_adm_router()
98709872
flags_with_completion=()
98719873
flags_completion=()
98729874

9875+
flags+=("--ciphers=")
9876+
local_nonpersistent_flags+=("--ciphers=")
98739877
flags+=("--create")
98749878
local_nonpersistent_flags+=("--create")
98759879
flags+=("--default-cert=")
@@ -23201,6 +23205,8 @@ _openshift_infra_router()
2320123205
flags_with_completion+=("--certificate-authority")
2320223206
flags_completion+=("_filedir")
2320323207
local_nonpersistent_flags+=("--certificate-authority=")
23208+
flags+=("--ciphers=")
23209+
local_nonpersistent_flags+=("--ciphers=")
2320423210
flags+=("--client-certificate=")
2320523211
flags_with_completion+=("--client-certificate")
2320623212
flags_completion+=("_filedir")

contrib/completions/zsh/oadm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,6 +4888,8 @@ _oadm_router()
48884888
flags_with_completion=()
48894889
flags_completion=()
48904890

4891+
flags+=("--ciphers=")
4892+
local_nonpersistent_flags+=("--ciphers=")
48914893
flags+=("--create")
48924894
local_nonpersistent_flags+=("--create")
48934895
flags+=("--default-cert=")

contrib/completions/zsh/oc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4891,6 +4891,8 @@ _oc_adm_router()
48914891
flags_with_completion=()
48924892
flags_completion=()
48934893

4894+
flags+=("--ciphers=")
4895+
local_nonpersistent_flags+=("--ciphers=")
48944896
flags+=("--create")
48954897
local_nonpersistent_flags+=("--create")
48964898
flags+=("--default-cert=")

contrib/completions/zsh/openshift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,6 +4888,8 @@ _openshift_admin_router()
48884888
flags_with_completion=()
48894889
flags_completion=()
48904890

4891+
flags+=("--ciphers=")
4892+
local_nonpersistent_flags+=("--ciphers=")
48914893
flags+=("--create")
48924894
local_nonpersistent_flags+=("--create")
48934895
flags+=("--default-cert=")
@@ -10019,6 +10021,8 @@ _openshift_cli_adm_router()
1001910021
flags_with_completion=()
1002010022
flags_completion=()
1002110023

10024+
flags+=("--ciphers=")
10025+
local_nonpersistent_flags+=("--ciphers=")
1002210026
flags+=("--create")
1002310027
local_nonpersistent_flags+=("--create")
1002410028
flags+=("--default-cert=")
@@ -23350,6 +23354,8 @@ _openshift_infra_router()
2335023354
flags_with_completion+=("--certificate-authority")
2335123355
flags_completion+=("_filedir")
2335223356
local_nonpersistent_flags+=("--certificate-authority=")
23357+
flags+=("--ciphers=")
23358+
local_nonpersistent_flags+=("--ciphers=")
2335323359
flags+=("--client-certificate=")
2335423360
flags_with_completion+=("--client-certificate")
2335523361
flags_completion+=("_filedir")

images/router/haproxy/conf/haproxy-config.template

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,34 @@ global
2727
# TODO: use when 1.5.14 is available
2828
# ssl-default-bind-options no-sslv3
2929

30+
# The default cipher suite can be selected from the three sets recommended by https://wiki.mozilla.org/Security/Server_Side_TLS,
31+
# or the user can provide one using the ROUTER_CIPHERS environment variable.
32+
# By default when a cipher set is not provided, intermediate is used.
33+
{{- if eq (env "ROUTER_CIPHERS" "intermediate") "modern" }}
3034
# Modern cipher suite (no legacy browser support) from https://wiki.mozilla.org/Security/Server_Side_TLS
31-
# tune.ssl.default-dh-param 2048
32-
# ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
35+
tune.ssl.default-dh-param 2048
36+
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
37+
{{ else }}
3338

39+
{{- if eq (env "ROUTER_CIPHERS" "intermediate") "intermediate" }}
3440
# Intermediate cipher suite (default) from https://wiki.mozilla.org/Security/Server_Side_TLS
3541
tune.ssl.default-dh-param 2048
3642
ssl-default-bind-ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
43+
{{ else }}
44+
45+
{{- if eq (env "ROUTER_CIPHERS" "intermediate") "old" }}
3746

3847
# Old cipher suite (maximum compatibility but insecure) from https://wiki.mozilla.org/Security/Server_Side_TLS
39-
# tune.ssl.default-dh-param 1024
40-
# ssl-default-bind-ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP
48+
tune.ssl.default-dh-param 1024
49+
ssl-default-bind-ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP
50+
51+
{{- else }}
52+
# user provided list of ciphers (Colon separated list as seen above)
53+
tune.ssl.default-dh-param 2048
54+
ssl-default-bind-ciphers {{env "ROUTER_CIPHERS" "ECDHE-ECDSA-CHACHA20-POLY1305"}}
55+
{{- end }}
56+
{{- end }}
57+
{{- end }}
4158

4259
defaults
4360
maxconn {{env "ROUTER_MAX_CONNECTIONS" "20000"}}

pkg/cmd/admin/router/router.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ type RouterConfig struct {
226226
// MetricsImage is the image to run a sidecar container with in the router
227227
// pod.
228228
MetricsImage string
229+
230+
// Ciphers is the set of ciphers to use with bind
231+
// modern | intermediate | old | set of cihers
232+
Ciphers string
229233
}
230234

231235
const (
@@ -305,6 +309,7 @@ func NewCmdRouter(f *clientcmd.Factory, parentName, name string, out, errout io.
305309
cmd.Flags().StringVar(&cfg.ExternalHostPartitionPath, "external-host-partition-path", cfg.ExternalHostPartitionPath, "If the underlying router implementation uses partitions for control boundaries, this is the path to use for that partition.")
306310
cmd.Flags().BoolVar(&cfg.DisableNamespaceOwnershipCheck, "disable-namespace-ownership-check", cfg.DisableNamespaceOwnershipCheck, "Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.")
307311
cmd.Flags().StringVar(&cfg.MaxConnections, "max-connections", cfg.MaxConnections, "Specifies the maximum number of concurrent connections. Not supported for F5.")
312+
cmd.Flags().StringVar(&cfg.Ciphers, "ciphers", cfg.Ciphers, "Specifies the cipher set (modern|intermediate|old) or the : separated list of ciphers to be used by bind. Not supported for F5.")
308313

309314
cfg.Action.BindForOutput(cmd.Flags())
310315
cmd.Flags().String("output-version", "", "The preferred API versions of the output objects")
@@ -644,6 +649,7 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
644649
"ROUTER_EXTERNAL_HOST_PRIVKEY": privkeyPath,
645650
"ROUTER_EXTERNAL_HOST_INTERNAL_ADDRESS": cfg.ExternalHostInternalIP,
646651
"ROUTER_EXTERNAL_HOST_VXLAN_GW_CIDR": cfg.ExternalHostVxLANGateway,
652+
"ROUTER_CIPHERS": cfg.Ciphers,
647653
"STATS_PORT": strconv.Itoa(cfg.StatsPort),
648654
"STATS_USERNAME": cfg.StatsUsername,
649655
"STATS_PASSWORD": cfg.StatsPassword,

pkg/cmd/infra/router/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type TemplateRouter struct {
7171
RouterService *ktypes.NamespacedName
7272
BindPortsAfterSync bool
7373
MaxConnections string
74+
Ciphers string
7475
MetricsType string
7576
}
7677

@@ -100,6 +101,7 @@ func (o *TemplateRouter) Bind(flag *pflag.FlagSet) {
100101
flag.BoolVar(&o.ExtendedValidation, "extended-validation", util.Env("EXTENDED_VALIDATION", "true") == "true", "If set, then an additional extended validation step is performed on all routes admitted in by this router. Defaults to true and enables the extended validation checks.")
101102
flag.BoolVar(&o.BindPortsAfterSync, "bind-ports-after-sync", util.Env("ROUTER_BIND_PORTS_AFTER_SYNC", "") == "true", "Bind ports only after route state has been synchronized")
102103
flag.StringVar(&o.MaxConnections, "max-connections", util.Env("ROUTER_MAX_CONNECTIONS", ""), "Specifies the maximum number of concurrent connections.")
104+
flag.StringVar(&o.Ciphers, "ciphers", util.Env("ROUTER_CIPHERS", ""), "Specifies the cipher set (modern,intermediate,old) or : separated cipher list to be used by bind.")
103105
flag.StringVar(&o.MetricsType, "metrics-type", util.Env("ROUTER_METRICS_TYPE", ""), "Specifies the type of metrics to gather. Supports 'haproxy'.")
104106
}
105107

@@ -299,6 +301,7 @@ func (o *TemplateRouterOptions) Run() error {
299301
IncludeUDP: o.RouterSelection.IncludeUDP,
300302
AllowWildcardRoutes: o.RouterSelection.AllowWildcardRoutes,
301303
MaxConnections: o.MaxConnections,
304+
Ciphers: o.Ciphers,
302305
}
303306

304307
oc, kc, err := o.Config.Clients()

pkg/router/template/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type TemplatePluginConfig struct {
5454
PeerService *ktypes.NamespacedName
5555
BindPortsAfterSync bool
5656
MaxConnections string
57+
Ciphers string
5758
}
5859

5960
// routerInterface controls the interaction of the plugin with the underlying router implementation

test/cmd/router.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ os::cmd::expect_failure_and_text 'oadm router --dry-run --host-network=false --h
4242
os::cmd::expect_failure_and_text 'oadm router --dry-run --host-network=false --host-ports=false --router-canonical-hostname=1.2.3.4 -o yaml' 'error: canonical hostname must not be an IP address'
4343
# max_conn
4444
os::cmd::expect_success_and_text 'oadm router --dry-run --host-network=false --host-ports=false --max-connections=14583 -o yaml' '14583'
45+
# ciphers
46+
os::cmd::expect_success_and_text 'oadm router --dry-run --host-network=false --host-ports=false --ciphers=modern -o yaml' 'modern'
4547

4648
# mount tls crt as secret
4749
os::cmd::expect_success_and_not_text 'oadm router --dry-run --host-network=false --host-ports=false -o yaml' 'value: /etc/pki/tls/private/tls.crt'

0 commit comments

Comments
 (0)