Move openssl specific code to opensslcertdb package
This commit is contained in:
parent
8dbfc208b9
commit
e2f4082755
3 changed files with 13 additions and 9 deletions
|
@ -37,6 +37,8 @@ import (
|
|||
"github.com/knadh/koanf/providers/file"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"git.cacert.org/cacert-goocsp/pkg/opensslcertdb"
|
||||
|
||||
"git.cacert.org/cacert-goocsp/pkg/ocsp"
|
||||
|
||||
"git.cacert.org/cacert-goocsp/pkg/ocspsource"
|
||||
|
@ -134,7 +136,7 @@ func configureIssuers(ctx context.Context, issuerConfigs []*koanf.Koanf, opts []
|
|||
continue
|
||||
}
|
||||
|
||||
certDb, err := ocspsource.NewCertDB(ctx, issuerConfig.String(issuerCertList))
|
||||
certDb, err := opensslcertdb.NewCertDB(ctx, issuerConfig.String(issuerCertList))
|
||||
if err != nil {
|
||||
logrus.Errorf("could not create certificate db %d: %v", number, err)
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ func newTestCertDB() *testCertDB {
|
|||
}
|
||||
|
||||
func (t testCertDB) LookupResponseTemplate(serial *big.Int) *ocsp.Response {
|
||||
serialText := serial.Text(hexBase)
|
||||
serialText := serial.Text(16)
|
||||
|
||||
if response, ok := t.content[serialText]; ok {
|
||||
return response
|
||||
|
@ -234,7 +234,7 @@ func (t testCertDB) LookupResponseTemplate(serial *big.Int) *ocsp.Response {
|
|||
}
|
||||
|
||||
func (t testCertDB) UpdateCertificate(update *CertificateUpdate) {
|
||||
t.content[update.Serial.Text(hexBase)] = &ocsp.Response{
|
||||
t.content[update.Serial.Text(16)] = &ocsp.Response{
|
||||
Status: update.Status,
|
||||
SerialNumber: update.Serial,
|
||||
RevokedAt: update.RevokedAt,
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package ocspsource
|
||||
package opensslcertdb
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
@ -33,6 +33,8 @@ import (
|
|||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"git.cacert.org/cacert-goocsp/pkg/ocspsource"
|
||||
|
||||
"git.cacert.org/cacert-goocsp/pkg/ocsp"
|
||||
)
|
||||
|
||||
|
@ -58,7 +60,7 @@ type OpenSSLCertDB struct {
|
|||
content map[string]*ocsp.Response
|
||||
}
|
||||
|
||||
func (o *OpenSSLCertDB) UpdateCertificate(update *CertificateUpdate) {
|
||||
func (o *OpenSSLCertDB) UpdateCertificate(update *ocspsource.CertificateUpdate) {
|
||||
o.content[update.Serial.Text(hexBase)] = &ocsp.Response{
|
||||
Status: update.Status,
|
||||
SerialNumber: update.Serial,
|
||||
|
@ -211,7 +213,7 @@ func (o *OpenSSLCertDB) watchIndexFile(watcher *fsnotify.Watcher) {
|
|||
}
|
||||
|
||||
// The parseLine function parses a line of index.txt.
|
||||
func parseLine(line string) *CertificateUpdate {
|
||||
func parseLine(line string) *ocspsource.CertificateUpdate {
|
||||
const (
|
||||
fieldSeparator = "\t"
|
||||
)
|
||||
|
@ -234,7 +236,7 @@ func parseLine(line string) *CertificateUpdate {
|
|||
return nil
|
||||
}
|
||||
|
||||
update := &CertificateUpdate{
|
||||
update := &ocspsource.CertificateUpdate{
|
||||
Serial: serialNumber,
|
||||
}
|
||||
|
||||
|
@ -268,7 +270,7 @@ func parseSerialNumber(parts []string) (string, *big.Int, error) {
|
|||
return serial, serialNumber, nil
|
||||
}
|
||||
|
||||
func mapStatusField(update *CertificateUpdate, parts []string) {
|
||||
func mapStatusField(update *ocspsource.CertificateUpdate, parts []string) {
|
||||
switch parts[idxStatus] {
|
||||
case "V":
|
||||
update.Status = ocsp.Good
|
||||
|
@ -292,7 +294,7 @@ func traceParsedCertificateLine(parts []string, serial string) {
|
|||
)
|
||||
}
|
||||
|
||||
func handleRevoked(response *CertificateUpdate, parts []string, serial string) error {
|
||||
func handleRevoked(response *ocspsource.CertificateUpdate, parts []string, serial string) error {
|
||||
const lenWithReason = 2
|
||||
|
||||
if parts[idxRevocation] == "" {
|
Loading…
Reference in a new issue