@@ -70,6 +70,11 @@ func BuildConfiguration(
70
70
nginxPlus = buildNginxPlus (gateway )
71
71
}
72
72
73
+ var gatewaySecretRef SSLKeyPairID
74
+ if gateway .Valid && gateway .SecretRef != nil {
75
+ gatewaySecretRef = generateSSLKeyPairID (* gateway .SecretRef )
76
+ }
77
+
73
78
config := Configuration {
74
79
HTTPServers : httpServers ,
75
80
SSLServers : sslServers ,
@@ -81,9 +86,10 @@ func BuildConfiguration(
81
86
gateway ,
82
87
serviceResolver ,
83
88
g .ReferencedServices ,
84
- baseHTTPConfig .IPFamily ),
89
+ baseHTTPConfig .IPFamily ,
90
+ ),
85
91
BackendGroups : backendGroups ,
86
- SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway . Listeners ),
92
+ SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway ),
87
93
CertBundles : buildCertBundles (
88
94
buildRefCertificateBundles (g .ReferencedSecrets , g .ReferencedCaCertConfigMaps ),
89
95
backendGroups ,
@@ -96,6 +102,7 @@ func BuildConfiguration(
96
102
MainSnippets : buildSnippetsForContext (gatewaySnippetsFilters , ngfAPIv1alpha1 .NginxContextMain ),
97
103
AuxiliarySecrets : buildAuxiliarySecrets (g .PlusSecrets ),
98
104
WorkerConnections : buildWorkerConnections (gateway ),
105
+ GatewaySecretID : gatewaySecretRef ,
99
106
}
100
107
101
108
return config
@@ -248,14 +255,14 @@ func buildStreamUpstreams(
248
255
}
249
256
250
257
// buildSSLKeyPairs builds the SSLKeyPairs from the Secrets. It will only include Secrets that are referenced by
251
- // valid listeners, so that we don't include unused Secrets in the configuration of the data plane.
258
+ // valid gateway and its listeners, so that we don't include unused Secrets in the configuration of the data plane.
252
259
func buildSSLKeyPairs (
253
260
secrets map [types.NamespacedName ]* graph.Secret ,
254
- listeners [] * graph.Listener ,
261
+ gateway * graph.Gateway ,
255
262
) map [SSLKeyPairID ]SSLKeyPair {
256
263
keyPairs := make (map [SSLKeyPairID ]SSLKeyPair )
257
264
258
- for _ , l := range listeners {
265
+ for _ , l := range gateway . Listeners {
259
266
if l .Valid && l .ResolvedSecret != nil {
260
267
id := generateSSLKeyPairID (* l .ResolvedSecret )
261
268
secret := secrets [* l .ResolvedSecret ]
@@ -268,6 +275,15 @@ func buildSSLKeyPairs(
268
275
}
269
276
}
270
277
278
+ if gateway .Valid && gateway .SecretRef != nil {
279
+ id := generateSSLKeyPairID (* gateway .SecretRef )
280
+ secret := secrets [* gateway .SecretRef ]
281
+ keyPairs [id ] = SSLKeyPair {
282
+ Cert : secret .CertBundle .Cert .TLSCert ,
283
+ Key : secret .CertBundle .Cert .TLSPrivateKey ,
284
+ }
285
+ }
286
+
271
287
return keyPairs
272
288
}
273
289
@@ -1042,8 +1058,6 @@ func buildBaseHTTPConfig(
1042
1058
}
1043
1059
}
1044
1060
1045
- baseConfig .RewriteClientIPSettings = buildRewriteClientIPConfig (np .RewriteClientIP )
1046
-
1047
1061
if np .Kubernetes != nil {
1048
1062
var containerSpec * ngfAPIv1alpha2.ContainerSpec
1049
1063
if np .Kubernetes .Deployment != nil {
@@ -1056,6 +1070,8 @@ func buildBaseHTTPConfig(
1056
1070
}
1057
1071
}
1058
1072
1073
+ baseConfig .RewriteClientIPSettings = buildRewriteClientIPConfig (np .RewriteClientIP )
1074
+
1059
1075
baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1060
1076
1061
1077
return baseConfig
0 commit comments