micromdm / scep

Go SCEP server
MIT License
323 stars 124 forks source link

BoltDB Depot serial number changes for data races #190

Closed jessepeterson closed 10 months ago

jessepeterson commented 2 years ago

Changes a few things to make serial number generation make a bit more sense. This brings the implementation in line with the following statements:

Depot.Serial() should always generate a unique new serial number. It's up to Depot.Put() to use the serial number in the generated certificate for storage, minding that there may very well be sequence gaps.

To that end adjust a bunch of things to make it conform to this. Add a mutex in case Serial() is called multiple times concurrently. Fix a few other unrelated things along the way. See also #185 for more context.