Skip to content

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

Merged
tsaarni merged 1 commit intomasterfrom
allow-parallel-generation
Jan 23, 2024
Merged

Fix race when generation of certificate or CRL can be called from multiple goroutines#48
tsaarni merged 1 commit intomasterfrom
allow-parallel-generation

Conversation

@tsaarni
Copy link
Copy Markdown
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 force-pushed the allow-parallel-generation branch from 17c5f1b to 3f46f02 Compare January 23, 2024 18:16
@tsaarni tsaarni merged commit 66a265c into master Jan 23, 2024
@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