mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
autocert: fix locking issue (#1310)
This commit is contained in:
parent
d81cfb6e99
commit
79741d5345
1 changed files with 4 additions and 5 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"sort"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/caddyserver/certmagic"
|
||||
|
@ -29,7 +30,7 @@ type Manager struct {
|
|||
mu sync.RWMutex
|
||||
config *config.Config
|
||||
certmagic *certmagic.Config
|
||||
acmeMgr *certmagic.ACMEManager
|
||||
acmeMgr atomic.Value
|
||||
srv *http.Server
|
||||
|
||||
config.ChangeDispatcher
|
||||
|
@ -81,7 +82,7 @@ func (mgr *Manager) getCertMagicConfig(options *config.Options) (*certmagic.Conf
|
|||
}
|
||||
acmeMgr.DisableTLSALPNChallenge = true
|
||||
mgr.certmagic.Issuer = acmeMgr
|
||||
mgr.acmeMgr = acmeMgr
|
||||
mgr.acmeMgr.Store(acmeMgr)
|
||||
|
||||
return mgr.certmagic, nil
|
||||
}
|
||||
|
@ -195,9 +196,7 @@ func (mgr *Manager) updateServer(cfg *config.Config) {
|
|||
}
|
||||
|
||||
func (mgr *Manager) handleHTTPChallenge(w http.ResponseWriter, r *http.Request) bool {
|
||||
mgr.mu.RLock()
|
||||
acmeMgr := mgr.acmeMgr
|
||||
mgr.mu.RUnlock()
|
||||
acmeMgr := mgr.acmeMgr.Load().(*certmagic.ACMEManager)
|
||||
if acmeMgr == nil {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue