|
|
|
@ -24,6 +24,7 @@ import (
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"math/big"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
"code.cacert.org/cacert/goocsp/pkg/filewatcher"
|
|
|
|
|
"code.cacert.org/cacert/goocsp/pkg/ocsp"
|
|
|
|
@ -35,6 +36,7 @@ import (
|
|
|
|
|
type CRLCertDB struct {
|
|
|
|
|
crlPath string
|
|
|
|
|
content map[string]*ocsp.Response
|
|
|
|
|
lock sync.Mutex
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewCertDB(ctx context.Context, crlPath string) (*CRLCertDB, error) {
|
|
|
|
@ -95,6 +97,9 @@ func (d *CRLCertDB) update() error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *CRLCertDB) UpdateCertificate(update *ocspsource.CertificateUpdate) {
|
|
|
|
|
d.lock.Lock()
|
|
|
|
|
defer d.lock.Unlock()
|
|
|
|
|
|
|
|
|
|
d.content[update.Serial.Text(16)] = &ocsp.Response{
|
|
|
|
|
Status: update.Status,
|
|
|
|
|
SerialNumber: update.Serial,
|
|
|
|
@ -104,6 +109,9 @@ func (d *CRLCertDB) UpdateCertificate(update *ocspsource.CertificateUpdate) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *CRLCertDB) LookupResponseTemplate(number *big.Int) *ocsp.Response {
|
|
|
|
|
d.lock.Lock()
|
|
|
|
|
defer d.lock.Unlock()
|
|
|
|
|
|
|
|
|
|
serial := number.Text(16)
|
|
|
|
|
if response, ok := d.content[serial]; ok {
|
|
|
|
|
return response
|
|
|
|
|