-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
src: enable X509sToArrayOfStrings to skip errors #61784
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
|
Review requested:
|
4801d72 to
88ad793
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61784 +/- ##
==========================================
- Coverage 89.73% 89.72% -0.02%
==========================================
Files 675 675
Lines 204674 204700 +26
Branches 39330 39338 +8
==========================================
Hits 183667 183667
- Misses 13283 13307 +24
- Partials 7724 7726 +2
🚀 New features to boost your workflow:
|
| std::string subject_str = "<unknown>"; | ||
| if (subject_bio) { | ||
| auto subject_size = | ||
| BIO_get_mem_data(subject_bio.get(), &subject_data); | ||
| if (subject_size > 0 && subject_data) { | ||
| subject_str = std::string(subject_data, subject_size); |
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.
| std::string subject_str = "<unknown>"; | |
| if (subject_bio) { | |
| auto subject_size = | |
| BIO_get_mem_data(subject_bio.get(), &subject_data); | |
| if (subject_size > 0 && subject_data) { | |
| subject_str = std::string(subject_data, subject_size); | |
| std::string_view subject_str = "<unknown>"; | |
| if (subject_bio) { | |
| auto subject_size = | |
| BIO_get_mem_data(subject_bio.get(), &subject_data); | |
| if (subject_size > 0 && subject_data) { | |
| subject_str = std::string_view(subject_data, subject_size); |
No good reason to do an extra heap allocation here
| per_process::Debug(DebugCategory::CRYPTO, | ||
| "Skipping system certificate with subject " | ||
| "'%s' because X509 to PEM conversion failed\n", | ||
| subject_str.c_str()); |
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.
| subject_str.c_str()); | |
| subject_str); |
| } | ||
|
|
||
| if (skipped > 0) { | ||
| ProcessEmitWarning( |
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.
I wonder if we should make this an option to the API instead of unconditionally emitting a warning? So if the user uses tls.getCACertifcate, they can choose warn, ignore, throw (or even get a list of errors on the side) when there's an error in parsing these certificates. For NODE_USE_SYSTEM_CA/--use-system-ca, warn is a sensible behavior.
As suggested in the linked issue, this PR relaxes the X509 to PEM conversion by skipping failures for system certs. If conversion fails, Node.js will try to give info about the failed certs if it can. This new behavior is used only on system certs, since for others, the user has control. AFAIK, there is no way to add a reliable test for this, but if someone has an idea, feel free to share it with me.
Fixes: #61636