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

windows root certificate scanning #14229

Merged
merged 6 commits into from
Jan 17, 2023
Merged

Conversation

star-tek-mb
Copy link
Contributor

Closes #14170

Works as expected.
Any code reviews are pleased.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Good work.

Would you mind using CertOpenSystemStoreW instead of CertOpenSystemStoreA? See #534 for more details.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing-

cb.bytes.clearRetainingCapacity();
cb.map.clearRetainingCapacity();

const store = os.windows.crypt32.CertOpenSystemStoreA(null, "ROOT");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function may fail. Please check for an error after this call.

Copy link
Contributor Author

@star-tek-mb star-tek-mb Jan 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. There is no documentation about possible errors, so I used unexpectedError. Also, used unreachable in closeStore function in defer clause (closeStore also can return error), because in any case, it will free memory (should I change it to do noop?). I hope this is ok. Also, I don't think that CertOpenSystemStoreW can return error, if i provide string other than "ROOT" (some other unexpected string), it doesn't seem to return any error. But in any case, i handled possible errors, i think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CertOpenSystemStoreW
Errors from the called function CertOpenStore are propagated to this function.

Which includes ERROR_FILE_NOT_FOUND.

CertOpenStore
CreateFile, ReadFile, or registry errors might be propagated and their error codes returned.

Alongside these all of the error codes associated with ReadFile and WriteFile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std.crypto.Certificate.Bundle: find system-installed root certificates on Windows
3 participants