@@ -25,22 +25,34 @@ index 5cbb8197f..82f6f9238 100644
25
25
+ })
26
26
+ }
27
27
diff --git a/pkg/util/tls/tls.go b/pkg/util/tls/tls.go
28
- index e9e140548..922ae9826 100644
28
+ index e9e140548..7e46688c6 100644
29
29
--- a/pkg/util/tls/tls.go
30
30
+++ b/pkg/util/tls/tls.go
31
- @@ -91,7 +91,7 @@ func SetupExportProxyTLS(certManager certificate.Manager, kubeVirtInformer cache
31
+ @@ -132,6 +132,57 @@ func SetupTLSWithCertManager(caManager ClientCAManager, certManager certificate.
32
32
return tlsConfig
33
33
}
34
34
35
- - func SetupTLSWithCertManager(caManager ClientCAManager, certManager certificate.Manager, clientAuth tls.ClientAuthType, clusterConfig *virtconfig.ClusterConfig) *tls.Config {
36
- + func SetupTLSWithCertManager(caManager, virtualizationCAManager ClientCAManager, certManager certificate.Manager, clientAuth tls.ClientAuthType, clusterConfig *virtconfig.ClusterConfig) *tls.Config {
37
- tlsConfig := &tls.Config{
38
- GetCertificate: func(info *tls.ClientHelloInfo) (certificate *tls.Certificate, err error) {
39
- cert := certManager.Current()
40
- @@ -112,6 +112,16 @@ func SetupTLSWithCertManager(caManager ClientCAManager, certManager certificate.
41
- return nil, err
42
- }
43
-
35
+ + func SetupTLSWithVirtualizationCAManager(caManager, virtualizationCAManager ClientCAManager, certManager certificate.Manager, clientAuth tls.ClientAuthType, clusterConfig *virtconfig.ClusterConfig) *tls.Config {
36
+ + tlsConfig := &tls.Config{
37
+ + GetCertificate: func(info *tls.ClientHelloInfo) (certificate *tls.Certificate, err error) {
38
+ + cert := certManager.Current()
39
+ + if cert == nil {
40
+ + return nil, fmt.Errorf(noSrvCertMessage)
41
+ + }
42
+ + return cert, nil
43
+ + },
44
+ + GetConfigForClient: func(hi *tls.ClientHelloInfo) (*tls.Config, error) {
45
+ + cert := certManager.Current()
46
+ + if cert == nil {
47
+ + return nil, fmt.Errorf(noSrvCertMessage)
48
+ + }
49
+ +
50
+ + clientCAPool, err := caManager.GetCurrent()
51
+ + if err != nil {
52
+ + log.Log.Reason(err).Error("Failed to get requestheader client CA")
53
+ + return nil, err
54
+ + }
55
+ +
44
56
+ virtualizationClientCAPool, err := virtualizationCAManager.GetCurrent()
45
57
+ if err != nil {
46
58
+ log.Log.Reason(err).Error("Failed to get CA from config-map virtualization-ca")
@@ -51,11 +63,31 @@ index e9e140548..922ae9826 100644
51
63
+ clientCAPool.AppendCertsFromPEM(subj)
52
64
+ }
53
65
+
54
- kv := clusterConfig.GetConfigFromKubeVirtCR()
55
- tlsConfig := getTLSConfiguration(kv)
56
- ciphers := CipherSuiteIds(tlsConfig.Ciphers)
66
+ + kv := clusterConfig.GetConfigFromKubeVirtCR()
67
+ + tlsConfig := getTLSConfiguration(kv)
68
+ + ciphers := CipherSuiteIds(tlsConfig.Ciphers)
69
+ + minTLSVersion := TLSVersion(tlsConfig.MinTLSVersion)
70
+ + config := &tls.Config{
71
+ + CipherSuites: ciphers,
72
+ + MinVersion: minTLSVersion,
73
+ + Certificates: []tls.Certificate{*cert},
74
+ + ClientCAs: clientCAPool,
75
+ + ClientAuth: clientAuth,
76
+ + }
77
+ +
78
+ + config.BuildNameToCertificate()
79
+ + return config, nil
80
+ + },
81
+ + }
82
+ + tlsConfig.BuildNameToCertificate()
83
+ + return tlsConfig
84
+ + }
85
+ +
86
+ func SetupTLSForVirtHandlerServer(caManager ClientCAManager, certManager certificate.Manager, externallyManaged bool, clusterConfig *virtconfig.ClusterConfig) *tls.Config {
87
+ // #nosec cause: InsecureSkipVerify: true
88
+ // resolution: Neither the client nor the server should validate anything itself, `VerifyPeerCertificate` is still executed
57
89
diff --git a/pkg/virt-api/api.go b/pkg/virt-api/api.go
58
- index 120f2d68f..8eaa011d2 100644
90
+ index 120f2d68f..4b82edd13 100644
59
91
--- a/pkg/virt-api/api.go
60
92
+++ b/pkg/virt-api/api.go
61
93
@@ -884,7 +884,7 @@ func (app *virtAPIApp) registerMutatingWebhook(informers *webhooks.Informers) {
@@ -72,7 +104,7 @@ index 120f2d68f..8eaa011d2 100644
72
104
// if the TLS handshake requests it. As a result, the TLS handshake fails
73
105
// and our aggregated endpoint never becomes available.
74
106
- app.tlsConfig = kvtls.SetupTLSWithCertManager(k8sCAManager, app.certmanager, tls.VerifyClientCertIfGiven, app.clusterConfig)
75
- + app.tlsConfig = kvtls.SetupTLSWithCertManager (k8sCAManager, virtualizationCAManager, app.certmanager, tls.VerifyClientCertIfGiven, app.clusterConfig)
107
+ + app.tlsConfig = kvtls.SetupTLSWithVirtualizationCAManager (k8sCAManager, virtualizationCAManager, app.certmanager, tls.VerifyClientCertIfGiven, app.clusterConfig)
76
108
app.handlerTLSConfiguration = kvtls.SetupTLSForVirtHandlerClients(kubevirtCAManager, app.handlerCertManager, app.externallyManaged)
77
109
}
78
110
0 commit comments