cert: fix GenerateCA returning nil error on self-signed cert failure - #2802
Open
bhuvan-somisetty wants to merge 2 commits into
Open
cert: fix GenerateCA returning nil error on self-signed cert failure#2802bhuvan-somisetty wants to merge 2 commits into
bhuvan-somisetty wants to merge 2 commits into
Conversation
bhuvan-somisetty
requested review from
Aryan-sharma11,
AryanBakliwal and
achrefbensaad
as code owners
July 24, 2026 22:07
Author
|
Hi @Aryan-sharma11 @achrefbensaad @AryanBakliwal @daemon1024 @nyrahul — could someone please take a look at this PR when you get a chance? It fixes #2689 by propagating errors from GenerateSelfSignedCert in GenerateCA() rather than swallowing them. Also added unit tests in cert_test.go. Thanks! |
bhuvan-somisetty
force-pushed
the
fix/cert-generateca-error-propagation
branch
2 times, most recently
from
July 24, 2026 22:13
0afc753 to
0a80103
Compare
vee1e
reviewed
Jul 26, 2026
When GenerateSelfSignedCert failed inside GenerateCA, the error was logged
and discarded, returning &CertBytes{} with a nil error. This caused callers to
mistakenly treat CA generation failures as successful.
Propagate the error returned by GenerateSelfSignedCert when self-signed certificate
generation fails, ensuring calling code receives error notifications.
Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
…onfig in tests Address review feedback: - GenerateCA now logs the self-signed cert failure before returning the error, matching the logging style used elsewhere in the file. - cert tests take a value copy of DefaultKubeArmorCAConfig instead of taking its address, so the package-level default is not mutated for the rest of the test process. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
AryanBakliwal
force-pushed
the
fix/cert-generateca-error-propagation
branch
from
August 19, 2026 09:52
c547c44 to
36d809e
Compare
AryanBakliwal
approved these changes
Aug 24, 2026
Aryan-sharma11
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of PR?:
In the
GenerateCAfunction inKubeArmor/cert/cert.go, whenGenerateSelfSignedCertfails, the error was logged and swallowed, returning an emptyCertBytesstruct with anilerror value (return &CertBytes{}, nil). Calling code was thus unable to detect certificate generation failures and proceeded with uninitialized or empty TLS certificates.This change ensures that
GenerateCApropagates the error returned byGenerateSelfSignedCert.Fixes #2689
Does this PR introduce a breaking change?
No
If the changes in this PR are manually verified, list down the scenarios covered::
TestGenerateCA_Successverifying CA certificate generation under normal conditions.TestGenerateCA_ErrorPropagationOnSelfSignedCertFailureverifying that errors during self-signed certificate creation are properly returned to the caller.Checklist:
<type>(<scope>): <subject>