mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +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"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/caddyserver/certmagic"
|
"github.com/caddyserver/certmagic"
|
||||||
|
@ -29,7 +30,7 @@ type Manager struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
config *config.Config
|
config *config.Config
|
||||||
certmagic *certmagic.Config
|
certmagic *certmagic.Config
|
||||||
acmeMgr *certmagic.ACMEManager
|
acmeMgr atomic.Value
|
||||||
srv *http.Server
|
srv *http.Server
|
||||||
|
|
||||||
config.ChangeDispatcher
|
config.ChangeDispatcher
|
||||||
|
@ -81,7 +82,7 @@ func (mgr *Manager) getCertMagicConfig(options *config.Options) (*certmagic.Conf
|
||||||
}
|
}
|
||||||
acmeMgr.DisableTLSALPNChallenge = true
|
acmeMgr.DisableTLSALPNChallenge = true
|
||||||
mgr.certmagic.Issuer = acmeMgr
|
mgr.certmagic.Issuer = acmeMgr
|
||||||
mgr.acmeMgr = acmeMgr
|
mgr.acmeMgr.Store(acmeMgr)
|
||||||
|
|
||||||
return mgr.certmagic, nil
|
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 {
|
func (mgr *Manager) handleHTTPChallenge(w http.ResponseWriter, r *http.Request) bool {
|
||||||
mgr.mu.RLock()
|
acmeMgr := mgr.acmeMgr.Load().(*certmagic.ACMEManager)
|
||||||
acmeMgr := mgr.acmeMgr
|
|
||||||
mgr.mu.RUnlock()
|
|
||||||
if acmeMgr == nil {
|
if acmeMgr == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue