Skip to content

Commit

Permalink
tls: Handle when OCSP responder cert expires before a response it iss…
Browse files Browse the repository at this point in the history
…ued (caddyserver#1922)

* Handle the case of an OCSP responder certificate expiring before an OCSP response it issued

* oops

* doh, gofmt
  • Loading branch information
alex authored and mholt committed Oct 16, 2017
1 parent 654f26c commit c6a2911
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion caddytls/maintain.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,15 @@ func DeleteOldStapleFiles() {
// meaning that it is not expedient to get an
// updated response from the OCSP server.
func freshOCSP(resp *ocsp.Response) bool {
nextUpdate := resp.NextUpdate
// If there is an OCSP responder certificate, and it expires before the
// OCSP response, use its expiration date as the end of the OCSP
// response's validity period.
if resp.Certificate != nil && resp.Certificate.NotAfter.Before(nextUpdate) {
nextUpdate = resp.Certificate.NotAfter
}
// start checking OCSP staple about halfway through validity period for good measure
refreshTime := resp.ThisUpdate.Add(resp.NextUpdate.Sub(resp.ThisUpdate) / 2)
refreshTime := resp.ThisUpdate.Add(nextUpdate.Sub(resp.ThisUpdate) / 2)
return time.Now().Before(refreshTime)
}

Expand Down

0 comments on commit c6a2911

Please sign in to comment.