aboutsummaryrefslogtreecommitdiff
path: root/certificate
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-03-04 16:14:29 -0500
committerAdnan Maolood <[email protected]>2021-03-04 16:20:57 -0500
commit688e7e28238412bf48ad3b99cbb3a715d83a77e2 (patch)
treef793dcf0828bbc7dc76daf410a9962ba7fcfd273 /certificate
parentcertificate.Store: Fix hostname registration check (diff)
downloadgo-gemini-688e7e28238412bf48ad3b99cbb3a715d83a77e2.tar.xz
go-gemini-688e7e28238412bf48ad3b99cbb3a715d83a77e2.zip
certificate: Fix deadlock in Store.Get
Diffstat (limited to 'certificate')
-rw-r--r--certificate/store.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/certificate/store.go b/certificate/store.go
index e606221..b93f571 100644
--- a/certificate/store.go
+++ b/certificate/store.go
@@ -106,7 +106,6 @@ func (s *Store) write(scope string, cert tls.Certificate) error {
// Get is suitable for use in a gemini.Server's GetCertificate field.
func (s *Store) Get(hostname string) (*tls.Certificate, error) {
s.mu.RLock()
- defer s.mu.RUnlock()
_, ok := s.scopes[hostname]
if !ok {
// Try wildcard
@@ -121,10 +120,11 @@ func (s *Store) Get(hostname string) (*tls.Certificate, error) {
_, ok = s.scopes["*"]
}
if !ok {
+ s.mu.RUnlock()
return nil, errors.New("unrecognized scope")
}
-
cert := s.certs[hostname]
+ s.mu.RUnlock()
// If the certificate is empty or expired, generate a new one.
if cert.Leaf == nil || cert.Leaf.NotAfter.Before(time.Now()) {