fix: validation for certificates#7734
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7734 +/- ##
==========================================
+ Coverage 72.81% 72.87% +0.06%
==========================================
Files 237 237
Lines 35623 35669 +46
==========================================
+ Hits 25938 25993 +55
+ Misses 7834 7830 -4
+ Partials 1851 1846 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
16c0013 to
e589c4a
Compare
| return nil, fmt.Errorf("%s/%s must contain valid %s and %s, unable to validate certificate in %s: %w", secret.Namespace, secret.Name, corev1.TLSCertKey, corev1.TLSPrivateKeyKey, corev1.TLSCertKey, err) | ||
| } | ||
|
|
||
| certBlock, _ := pem.Decode(certData) | ||
| certBlock, _ := pem.Decode(validData) |
There was a problem hiding this comment.
should we handle multiple pems for certificate bundles?
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
e589c4a to
b5e4c49
Compare
| // No errors but no valid PEM blocks found - PEM decoding failed | ||
| return nil, fmt.Errorf("unable to decode pem data for certificate") | ||
| } | ||
| return validData, nil |
There was a problem hiding this comment.
We are not returning the expired cert errors here if there is a valid cert. IMO we should return the error and log it as warning if validData is non empty.
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
|
hi @rudrakhp , @arkodg , @zhaohuabing , please review it when you have a moment. |
|
@kkk777-7 can you fix the conflict? |
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
|
/retest |
Signed-off-by: Arko Dasgupta <arkodg@users.noreply.github.com>
* fix: validation for certificates Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com>
What this PR does / why we need it:
Fix CA certificate validation.
Currently, CA certificate validation only check first block.
So, if user stores the CA bundle in Secret and first block is invalid (e.g. expired certificate), CA certificate validation fails.
This behavior causes #7608.
Fixed:
Support validating all block. and invalid block is exclude.
If no valid certificates exist, return ListenerError with
InvalidCertificateRefcondition.If valid certificates exist and invalid certificates exist, return ListenerError with
PartiallyInvalidCertificateRefcondition.Related PR
#7909
Tests
Which issue(s) this PR fixes:
Fixes #7608
Release Notes: Yes
Related and Reference Issue
kubernetes/ingress-nginx#4234 (comment)