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

Refactor cert store handling. #42

Merged
merged 1 commit into from
Nov 9, 2021
Merged

Refactor cert store handling. #42

merged 1 commit into from
Nov 9, 2021

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Nov 5, 2021

Refactor cert store handling.

With the previous behavior, the stores are closed immediately after any functions using them return. This is potentially problematic, as some functions return handles to the data that's inside the now closed store. It's counter-intuitive to the caller that certtostore may have already allowed Windows to release the store, despite the WinCertStore remaining open. Further, the store was closed with the CHECK_FLAG which allows any other handles associated with the store to leak if the caller doesn't clean them up.

The new behavior is to hold the any store handles open inside WinCertStore. These will be freed when the user calls Close() on the WinCertStore. Failure to do so will leak the handle, but this is arguably preferable to trapping the user into vague cases where handles may have been closed prematurely. It also allows the use of the FORCE_FLAG, which will help prevent leaking of associated handles as long as Close() is called.

@copybara-service copybara-service bot changed the title Refactor user and system cert store handling Refactor cert store handling. Nov 5, 2021
With the previous behavior, the stores are closed immediately after any functions using them return. This is potentially problematic, as some functions return handles to the data that's inside the now closed store. It's counter-intuitive to the caller that certtostore may have already allowed Windows to release the store, despite the WinCertStore remaining open. Further, the store was closed with the CHECK_FLAG which allows any other handles associated with the store to leak if the caller doesn't clean them up.

The new behavior is to hold the any store handles open inside WinCertStore. These will be freed when the user calls Close() on the WinCertStore. Failure to do so will leak the handle, but this is arguably preferable to trapping the user into vague cases where handles may have been closed prematurely. It also allows the use of the FORCE_FLAG, which will help prevent leaking of associated handles as long as Close() is called.

PiperOrigin-RevId: 408645486
@copybara-service copybara-service bot merged commit d1c9527 into master Nov 9, 2021
@copybara-service copybara-service bot deleted the test_407860877 branch November 9, 2021 18:28
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.

1 participant