@@ -70,6 +70,11 @@ func BuildConfiguration(
7070		nginxPlus  =  buildNginxPlus (gateway )
7171	}
7272
73+ 	var  gatewaySecretRef  SSLKeyPairID 
74+ 	if  gateway .Valid  &&  gateway .SecretRef  !=  nil  {
75+ 		gatewaySecretRef  =  generateSSLKeyPairID (* gateway .SecretRef )
76+ 	}
77+ 
7378	config  :=  Configuration {
7479		HTTPServers :           httpServers ,
7580		SSLServers :            sslServers ,
@@ -81,9 +86,10 @@ func BuildConfiguration(
8186			gateway ,
8287			serviceResolver ,
8388			g .ReferencedServices ,
84- 			baseHTTPConfig .IPFamily ),
89+ 			baseHTTPConfig .IPFamily ,
90+ 		),
8591		BackendGroups : backendGroups ,
86- 		SSLKeyPairs :   buildSSLKeyPairs (g .ReferencedSecrets , gateway . Listeners ),
92+ 		SSLKeyPairs :   buildSSLKeyPairs (g .ReferencedSecrets , gateway ),
8793		CertBundles : buildCertBundles (
8894			buildRefCertificateBundles (g .ReferencedSecrets , g .ReferencedCaCertConfigMaps ),
8995			backendGroups ,
@@ -96,6 +102,7 @@ func BuildConfiguration(
96102		MainSnippets :      buildSnippetsForContext (gatewaySnippetsFilters , ngfAPIv1alpha1 .NginxContextMain ),
97103		AuxiliarySecrets :  buildAuxiliarySecrets (g .PlusSecrets ),
98104		WorkerConnections : buildWorkerConnections (gateway ),
105+ 		GatewaySecretID :   gatewaySecretRef ,
99106	}
100107
101108	return  config 
@@ -248,14 +255,14 @@ func buildStreamUpstreams(
248255}
249256
250257// 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. 
252259func  buildSSLKeyPairs (
253260	secrets  map [types.NamespacedName ]* graph.Secret ,
254- 	listeners  [] * graph.Listener ,
261+ 	gateway   * graph.Gateway ,
255262) map [SSLKeyPairID ]SSLKeyPair  {
256263	keyPairs  :=  make (map [SSLKeyPairID ]SSLKeyPair )
257264
258- 	for  _ , l  :=  range  listeners  {
265+ 	for  _ , l  :=  range  gateway . Listeners  {
259266		if  l .Valid  &&  l .ResolvedSecret  !=  nil  {
260267			id  :=  generateSSLKeyPairID (* l .ResolvedSecret )
261268			secret  :=  secrets [* l .ResolvedSecret ]
@@ -268,6 +275,15 @@ func buildSSLKeyPairs(
268275		}
269276	}
270277
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+ 
271287	return  keyPairs 
272288}
273289
@@ -1042,8 +1058,6 @@ func buildBaseHTTPConfig(
10421058		}
10431059	}
10441060
1045- 	baseConfig .RewriteClientIPSettings  =  buildRewriteClientIPConfig (np .RewriteClientIP )
1046- 
10471061	if  np .Kubernetes  !=  nil  {
10481062		var  containerSpec  * ngfAPIv1alpha2.ContainerSpec 
10491063		if  np .Kubernetes .Deployment  !=  nil  {
@@ -1056,6 +1070,8 @@ func buildBaseHTTPConfig(
10561070		}
10571071	}
10581072
1073+ 	baseConfig .RewriteClientIPSettings  =  buildRewriteClientIPConfig (np .RewriteClientIP )
1074+ 
10591075	baseConfig .DNSResolver  =  buildDNSResolverConfig (np .DNSResolver )
10601076
10611077	return  baseConfig 
0 commit comments