Skip to content
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

crypto: return clear errors when loading invalid PFX data #49566

Merged
merged 2 commits into from
Sep 29, 2023

Conversation

pimterry
Copy link
Member

@pimterry pimterry commented Sep 8, 2023

This fixes #49562

Without this change, the provided test fails with 'passed a null parameter', telling you nothing about what's actually wrong (since no nulls are present in this test code).

With this change, the test correctly receives a 'Unable to load private key from PFX data' error, telling you exactly what's wrong.

I've also covered the cert case here. I have confirmed that the same 'null parameter' error would be unhelpfully thrown if cert was null, so I think that's similarly useful. I'm not sure how to actually produce a pfx that would trigger this, so I haven't included a test, and it's possible that this isn't a possible condition (i.e. maybe PKCS12_parse would fail in that case) but it seems likely that it's technically possible and worth covering, and it's very easy to do so.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Sep 8, 2023
src/crypto/crypto_context.cc Outdated Show resolved Hide resolved
src/crypto/crypto_context.cc Outdated Show resolved Hide resolved
src/crypto/crypto_context.cc Outdated Show resolved Hide resolved
@debadree25 debadree25 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Sep 12, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 12, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@pimterry
Copy link
Member Author

This is reviewed & passing CI, I think it's ready to go AFAICT. Can somebody please add to the commit queue?

@aduh95 aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Sep 29, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 29, 2023
@nodejs-github-bot nodejs-github-bot merged commit 17b9925 into nodejs:main Sep 29, 2023
33 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 17b9925

@pimterry
Copy link
Member Author

Amazing thanks @aduh95!

alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
targos pushed a commit that referenced this pull request Nov 11, 2023
debadree25 pushed a commit to debadree25/node that referenced this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide clearer error messages when a TLS pfx does not contain a private key
6 participants