mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 19:06:33 +02:00
33 lines
647 B
Go
33 lines
647 B
Go
package autocert
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
lru "github.com/hashicorp/golang-lru"
|
|
)
|
|
|
|
type ocspCache struct {
|
|
*lru.Cache
|
|
}
|
|
|
|
func newOCSPCache(size int) (*ocspCache, error) {
|
|
c, err := lru.New(size)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ocspCache{c}, nil
|
|
}
|
|
|
|
// updated checks if OCSP response for this certificate was updated
|
|
func (c ocspCache) updated(key string, ocspResp []byte) bool {
|
|
current, there := c.Get(key)
|
|
if !there {
|
|
_ = c.Add(key, ocspResp)
|
|
return false // to avoid triggering reload first time we see this response
|
|
}
|
|
if bytes.Equal(current.([]byte), ocspResp) {
|
|
return false
|
|
}
|
|
_ = c.Add(key, ocspResp)
|
|
return true
|
|
}
|