|
@ -16,15 +16,16 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type certConfig struct { |
|
|
type certConfig struct { |
|
|
start, end time.Time |
|
|
tlsConf *tls.Config |
|
|
tlsConf *tls.Config |
|
|
sha256 [32]byte // cached from the tlsConf
|
|
|
sha256 [32]byte // cached from the tlsConf
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func newCertConfig(start, end time.Time, conf *tls.Config) (*certConfig, error) { |
|
|
func newCertConfig(start, end time.Time) (*certConfig, error) { |
|
|
|
|
|
conf, err := getTLSConf(start, end) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
return &certConfig{ |
|
|
return &certConfig{ |
|
|
start: start, |
|
|
|
|
|
end: end, |
|
|
|
|
|
tlsConf: conf, |
|
|
tlsConf: conf, |
|
|
sha256: sha256.Sum256(conf.Certificates[0].Leaf.Raw), |
|
|
sha256: sha256.Sum256(conf.Certificates[0].Leaf.Raw), |
|
|
}, nil |
|
|
}, nil |
|
@ -75,11 +76,7 @@ func newCertManager(clock clock.Clock) (*certManager, error) { |
|
|
func (m *certManager) init() error { |
|
|
func (m *certManager) init() error { |
|
|
start := m.clock.Now() |
|
|
start := m.clock.Now() |
|
|
end := start.Add(certValidity) |
|
|
end := start.Add(certValidity) |
|
|
tlsConf, err := getTLSConf(start, end) |
|
|
cc, err := newCertConfig(start, end) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
cc, err := newCertConfig(start, end, tlsConf) |
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
@ -94,11 +91,7 @@ func (m *certManager) background(t *clock.Ticker) error { |
|
|
return nil |
|
|
return nil |
|
|
case start := <-t.C: |
|
|
case start := <-t.C: |
|
|
end := start.Add(certValidity) |
|
|
end := start.Add(certValidity) |
|
|
tlsConf, err := getTLSConf(start, end) |
|
|
cc, err := newCertConfig(start, end) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
cc, err := newCertConfig(start, end, tlsConf) |
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|