amalsaidov opened a new pull request, #2917:
URL: https://github.com/apache/apisix-ingress-controller/pull/2917

   ### Type of change:
   
   - [x] Bugfix
   
   ### What this PR does / why we need it:
   
   A Gateway listener may declare more than one TLS `certificateRef`. In 
`translateSecret`, the loop that builds the SSL objects iterates over 
`listener.TLS.CertificateRefs` with the loop variable `ref`, but the `Kind` 
guard and the resolved Secret name were read from the hardcoded first element 
`listener.TLS.CertificateRefs[0]` instead of `ref`:
   
   ```go
   for refIndex, ref := range listener.TLS.CertificateRefs {
       ...
       if listener.TLS.CertificateRefs[0].Kind != nil && 
*listener.TLS.CertificateRefs[0].Kind == internaltypes.KindSecret {
           ...
           name := listener.TLS.CertificateRefs[0].Name
   ```
   
   Consequences:
   
   - The per-ref `Kind` check always inspects the first ref. If the first 
`certificateRef` is not a `Secret`, every remaining (valid) `Secret` ref on the 
listener is skipped and no SSL is programmed for it. Conversely, if the first 
ref is a `Secret`, later refs of a different kind are processed as if they were 
Secrets.
   - The error returned when a Secret has no data (`no secret data found for 
%s/%s`) always reports the first ref's name, not the ref that actually failed.
   
   The fix uses the current `ref` for both the `Kind` check and the name, so 
each `certificateRef` is evaluated on its own.
   
   ### Pre-submission checklist:
   
   - [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   - [x] Have you added corresponding test cases?
   - [ ] Have you modified the corresponding document?
   - [x] Is this PR backward compatible?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to