-
Notifications
You must be signed in to change notification settings - Fork 151
Implement more options for req CLI #2775
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
base: main
Are you sure you want to change the base?
Conversation
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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 11. Check the log or trigger a new build to see more.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2775 +/- ##
==========================================
+ Coverage 78.42% 78.43% +0.01%
==========================================
Files 683 683
Lines 116286 117177 +891
Branches 16401 16477 +76
==========================================
+ Hits 91197 91911 +714
- Misses 24215 24381 +166
- Partials 874 885 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
clang-tidy made some suggestions
ced2f39 to
b504f7e
Compare
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.
clang-tidy made some suggestions
justsmth
left a comment
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.
Codecov shows most of req.cc as not being covered -- the logic seems to be mostly covered by comparison tests, but apparently not by unit tests. We should have unit tests to provide better coverage and possibly hit a few edge cases that aren't easily covered by comparisons.
|
Also a couple of the Openssl comparison tests are failing for this: |
| TEST_F(ReqTest, DefaultKeyoutPath) { | ||
| // Test that key is written to privkey.pem when -keyout is not specified |
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.
In some CI setups this test might be run in parallel, which creates a race condition since the "privkey.pem" created by one run could be deleted or overwritten by another.
c577d68 to
7727746
Compare
| // Check if keys are RSA type | ||
| if (EVP_PKEY_id(key1) != EVP_PKEY_RSA) { | ||
| std::cout << "AWS-LC key is not an RSA key" << std::endl; | ||
| return false; | ||
| } | ||
|
|
||
| if (EVP_PKEY_id(key2) != EVP_PKEY_RSA) { | ||
| std::cout << "OpenSSL key is not an RSA key" << std::endl; | ||
| return false; | ||
| } | ||
|
|
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.
aren't these unreachable due to L497?
| // Check if keys are RSA type | ||
| if (EVP_PKEY_id(key1) != EVP_PKEY_RSA) { | ||
| std::cout << "AWS-LC key is not an RSA key" << std::endl; | ||
| return false; | ||
| } | ||
|
|
||
| if (EVP_PKEY_id(key2) != EVP_PKEY_RSA) { | ||
| std::cout << "OpenSSL key is not an RSA key" << std::endl; | ||
| return false; | ||
| } |
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.
also unreachable?
| X509_NAME *name2 = X509_REQ_get_subject_name(csr2); | ||
| if (X509_NAME_cmp(name1, name2) != 0) { | ||
|
|
||
| if (!name1 || !name2) { |
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.
don't you still need to call X509_NAME_cmp on the subject names?
| bssl::UniquePtr<BIO> output_bio; | ||
| if (out_path.empty()) { | ||
| output_bio.reset(BIO_new_fp(stdout, BIO_CLOSE)); | ||
| output_bio.reset(BIO_new_fp(stdout, BIO_NOCLOSE)); |
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.
here and elsewhere, why change this flag?
| // Parse keyspec | ||
| if (OPENSSL_strncasecmp(keyspec, "rsa:", 4) == 0) { | ||
| char *endptr = NULL; | ||
| errno = 0; |
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.
hm, it's not generally a good practice to set errno directly in the application layer
The <errno.h> header file defines the integer variable errno,
which is set by system calls and some library functions in the
event of an error to indicate what went wrong.
https://man7.org/linux/man-pages/man3/errno.3.html
why do we do so here?
| "basicConstraints=critical,CA:true\n"; | ||
|
|
||
| // Create a BIO for the config | ||
| bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(default_config, -1)); |
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.
do we have an upper bound on the buffer size here? negative length is not encouraged for new usages
Lines 461 to 463 in 981c79b
| // If |len| is negative, then |buf| is treated as a NUL-terminated string, but | |
| // don't depend on this in new code. | |
| OPENSSL_EXPORT BIO *BIO_new_mem_buf(const void *buf, ossl_ssize_t len); |
Issues:
Resolves #CryptoAlg-3380
Description of changes:
Implement the following options for x509 cli command:
Testing:
Unit tests added, including missing coverage for some existing x509 options.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.