Skip to content

Commit

Permalink
protect depot with mutex in SignCSR (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
korylprince authored Mar 18, 2022
1 parent f06bdce commit 6dcd663
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions depot/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package depot
import (
"crypto/rand"
"crypto/x509"
"sync"
"time"

"github.com/micromdm/scep/v2/cryptoutil"
Expand All @@ -12,6 +13,7 @@ import (
// Signer signs x509 certificates and stores them in a Depot
type Signer struct {
depot Depot
mu sync.Mutex
caPass string
allowRenewalDays int
validityDays int
Expand Down Expand Up @@ -61,6 +63,9 @@ func (s *Signer) SignCSR(m *scep.CSRReqMessage) (*x509.Certificate, error) {
return nil, err
}

s.mu.Lock()
defer s.mu.Unlock()

serial, err := s.depot.Serial()
if err != nil {
return nil, err
Expand Down

0 comments on commit 6dcd663

Please sign in to comment.