Skip to content

Commit 0703474

Browse files
Merge pull request #4244 from pacevedom/USHIFT-4932
USHIFT-4932: TLS config options for api server
2 parents 6a774fc + d78aef7 commit 0703474

File tree

21 files changed

+1637
-23
lines changed

21 files changed

+1637
-23
lines changed

cmd/generate-config/config/config-openapi-spec.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"required": [
1919
"auditLog",
2020
"namedCertificates",
21-
"subjectAltNames"
21+
"subjectAltNames",
22+
"tls"
2223
],
2324
"properties": {
2425
"advertiseAddress": {
@@ -89,6 +90,31 @@
8990
"items": {
9091
"type": "string"
9192
}
93+
},
94+
"tls": {
95+
"type": "object",
96+
"required": [
97+
"cipherSuites",
98+
"minVersion"
99+
],
100+
"properties": {
101+
"cipherSuites": {
102+
"description": "CipherSuites lists the allowed cipher suites that the API server will\naccept and serve. Defaults to cipher suites from the minVersion config\nparameter.",
103+
"type": "array",
104+
"items": {
105+
"type": "string"
106+
}
107+
},
108+
"minVersion": {
109+
"description": "MinVersion specifies which TLS version is the minimum version of TLS\nto serve from the API server. Allowed values: VersionTLS12, VersionTLS13.\nDefaults to VersionTLS12.",
110+
"type": "string",
111+
"default": "VersionTLS12",
112+
"enum": [
113+
"VersionTLS12",
114+
"VersionTLS13"
115+
]
116+
}
117+
}
92118
}
93119
}
94120
},

docs/user/howto_config.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ apiServer:
2121
- ""
2222
subjectAltNames:
2323
- ""
24+
tls:
25+
cipherSuites:
26+
- ""
27+
minVersion: ""
2428
debugging:
2529
logLevel: ""
2630
dns:
@@ -102,6 +106,10 @@ apiServer:
102106
- ""
103107
subjectAltNames:
104108
- ""
109+
tls:
110+
cipherSuites:
111+
- ""
112+
minVersion: VersionTLS12
105113
debugging:
106114
logLevel: Normal
107115
dns:

etcd/cmd/microshift-etcd/run.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"syscall"
1313
"time"
1414

15+
configv1 "github.com/openshift/api/config/v1"
1516
"github.com/openshift/microshift/pkg/config"
1617
"github.com/openshift/microshift/pkg/util/cryptomaterial"
1718

@@ -38,15 +39,6 @@ func NewRunEtcdCommand() *cobra.Command {
3839
return cmd
3940
}
4041

41-
var tlsCipherSuites = []string{
42-
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
43-
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
44-
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
45-
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
46-
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
47-
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
48-
}
49-
5042
type EtcdService struct {
5143
etcdCfg *etcd.Config
5244
minDefragBytes int64
@@ -92,7 +84,10 @@ func (s *EtcdService) configure(cfg *config.Config) {
9284
s.etcdCfg.Name = cfg.Node.HostnameOverride
9385
s.etcdCfg.InitialCluster = fmt.Sprintf("%s=https://%s:2380", cfg.Node.HostnameOverride, "localhost")
9486

95-
s.etcdCfg.CipherSuites = tlsCipherSuites
87+
s.etcdCfg.TlsMinVersion = getTLSMinVersion(cfg.ApiServer.TLS.MinVersion)
88+
if cfg.ApiServer.TLS.MinVersion != string(configv1.VersionTLS13) {
89+
s.etcdCfg.CipherSuites = cfg.ApiServer.TLS.CipherSuites
90+
}
9691
s.etcdCfg.ClientTLSInfo.CertFile = cryptomaterial.PeerCertPath(etcdServingCertDir)
9792
s.etcdCfg.ClientTLSInfo.KeyFile = cryptomaterial.PeerKeyPath(etcdServingCertDir)
9893
s.etcdCfg.ClientTLSInfo.TrustedCAFile = etcdSignerCertPath
@@ -188,6 +183,16 @@ func setURL(hostnames []string, port string) []url.URL {
188183
return urls
189184
}
190185

186+
func getTLSMinVersion(minVersion string) string {
187+
switch minVersion {
188+
case string(configv1.VersionTLS12):
189+
return "TLS1.2"
190+
case string(configv1.VersionTLS13):
191+
return "TLS1.3"
192+
}
193+
return ""
194+
}
195+
191196
// The following 'fragemented' logic is copied from the Openshift Cluster Etcd Operator.
192197
//
193198
// https://github.com/openshift/cluster-etcd-operator/blob/0584b0d1c8868535baf889d8c199f605aef4a3ae/pkg/operator/defragcontroller/defragcontroller.go#L282

etcd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
k8s.io/cli-runtime v0.0.0
1919
k8s.io/component-base v0.31.1
2020
k8s.io/klog/v2 v2.130.1
21-
k8s.io/kubectl v0.0.0
21+
k8s.io/kubectl v0.31.3
2222
sigs.k8s.io/yaml v1.4.0
2323
)
2424

etcd/vendor/github.com/openshift/library-go/pkg/crypto/OWNERS

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)