-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
operator/pkg/certs: validate X509 Cert key types and improve error handling #5561
operator/pkg/certs: validate X509 Cert key types and improve error handling #5561
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5561 +/- ##
==========================================
+ Coverage 34.14% 39.75% +5.60%
==========================================
Files 643 650 +7
Lines 44524 55131 +10607
==========================================
+ Hits 15203 21915 +6712
- Misses 28165 31809 +3644
- Partials 1156 1407 +251
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/assign |
The method /remove-kind bug |
/retest |
@XiShanYongYe-Chang all test cases passed :) |
Hi @XiShanYongYe-Chang and @zhzhuang-zju, Could we please get this PR merged? The unit test certificates PR (#5625 and #5559), which depends on this, has been stale for a while. If anything is needed to move it forward, please let me know. Thanks! 🙏 |
Hi @zhzhuang-zju, can you help take a review? |
sure, review is in progress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, others LGTM
a2171c3
to
70a5d9e
Compare
Thanks @zhzhuang-zju for the feedback! I've integrated it! Could you please take a look if everything looks good? 🙏 |
In this commit, we enhance the `GeneratePrivateKey` and `ParsePrivateKeyPEM` functions: - Added validation for unsupported key types and provided a more descriptive error message. This function supports ECDSA (using P-256) and RSA (with a key size of 3072 bits) algorithms. It returns an error for unsupported key types. - Improved error handling to include the type of the unsupported key format in the error message. This function now provides more informative feedback when the private key format is neither RSA nor ECDSA. Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
70a5d9e
to
ad7a70b
Compare
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks~
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: XiShanYongYe-Chang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
In this commit, we enhance the
GeneratePrivateKey
andParsePrivateKeyPEM
functions:Motivation and Context
During the testing of the Certificate Manager and Karmada Store (#5559), it was observed that when unsupported key types such as
UnknownPublicKeyAlgorithm
,DSA
, orEd25519
(as documented in the Go standard library crypto package) are passed to theGeneratePrivateKey
function, the function incorrectly returns anRSA
key. Instead, it should return an error when encountering unsupported key types.What type of PR is this?
/kind bug
Does this PR introduce a user-facing change?: