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

Fix race when generation of certificate or CRL can be called from multiple goroutines #48

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

tsaarni
Copy link
Owner

@tsaarni tsaarni commented Jan 23, 2024

This PR fixes a race condition that is triggered when Certificate or CRL get instantiated via multiple threads using the lazy initialization method.

This happens in following scenario:

  1. Global Certificate or CRL instance is created
  2. Function that does lazy initialization of the object, such as Certificate.PEM(), is called from multiple goroutines. This can happen when e.g. test cases are executed in parallel and they access single shared instance of Certificate or CRL

The fix does not attempt to cover explicitly regenerating certificate and key concurrently by calling Certificate.Generate() from multiple goroutines. The reason is that it would not be possible to synchronize "accessor" calls such as Certificate.PEM() with the re-generation, so synchronization would need to be on caller side for this use case.

Fixes #47

@tsaarni tsaarni merged commit 66a265c into master Jan 23, 2024
4 checks passed
@tsaarni tsaarni deleted the allow-parallel-generation branch January 23, 2024 20:17
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.

Parallel generation of Certificates and CRLs causes race condition
1 participant