-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
feat: added support for reading certificates from macOS system store #56599
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
8fd32ce
to
f3c212c
Compare
ReadSystemStoreCertificates(&combined_root_certs); | ||
} | ||
|
||
std::vector<Local<Value>> result(combined_root_certs.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.
This should be a LocalVector
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.
Would it be possible to use GitHub's suggestion feature please? I've tried a few options and not quite sure how to make it work.
std::vector<X509*> system_root_certificates_X509; | ||
for (int i = 0; i < count ; ++i) { | ||
SecCertificateRef certRef = (SecCertificateRef) CFArrayGetValueAtIndex( | ||
currAnchors, i); |
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.
This should use reinterpret_cast
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.
This fails to build with:
../../src/crypto/crypto_context.cc:447:33: error: reinterpret_cast from 'const void *' to 'SecCertificateRef' (aka '__SecCertificate *') casts away qualifiers
447 | SecCertificateRef certRef = reinterpret_cast<SecCertificateRef>(CFArrayGetValueAtIndex(
The linter hasn't asked me to change to it and it did in most of the other places.
src/crypto/crypto_context.cc
Outdated
char* issuer = reinterpret_cast<char *>(calloc(resultLen + 1, 1)); | ||
BIO_read(bio, issuer, resultLen); | ||
BIO_free_all(bio); | ||
|
||
std::string str(issuer); |
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.
No need to doubly allocate the string, doing it like in stdStringFromCF
should be fine
Would it be possible for someone to re-open the feature request please? #39657. It was closed due to being stale / no progress on it. |
Fixes #39657
Builds on #44532 but for macOS
TODO:
Happy to refactor heavily, I haven't used c++ before and I wrote it initially in objective c and ported it across.
This is heavily based upon chromium and some of OpenJDK along with a PR I have open with OpenJDK
Testing
I'm using https://github.com/timja/openjdk-intermediate-ca-reproducer as a reproducer:
Install the certificates, either by adding to keychain manually (see README) or using
/usr/bin/security
(see what the test is doing in this PR.main.js
/Users/$USER/projects/node/out/Release/node --use-system-ca main.js