@@ -12,6 +12,7 @@ import (
12
12
"strings"
13
13
"time"
14
14
15
+ "github.com/cloudflare/cfssl/certdb"
15
16
"github.com/cloudflare/cfssl/helpers"
16
17
"github.com/cloudflare/cfssl/log"
17
18
)
@@ -73,6 +74,27 @@ func NewCRLFromFile(serialList, issuerFile, keyFile []byte, expiryTime string) (
73
74
return CreateGenericCRL (revokedCerts , key , issuerCert , newExpiryTime )
74
75
}
75
76
77
+ // NewCRLFromDB takes in a list of CertificateRecords, as well as the issuing certificate
78
+ // of the CRL, and the private key. This function is then used to parse the records and generate a CRL
79
+ func NewCRLFromDB (certs []certdb.CertificateRecord , issuerCert * x509.Certificate , key crypto.Signer , expiryTime time.Duration ) ([]byte , error ) {
80
+ var revokedCerts []pkix.RevokedCertificate
81
+
82
+ newExpiryTime := time .Now ().Add (expiryTime )
83
+
84
+ // For every record, create a new revokedCertificate and add it to slice
85
+ for _ , certRecord := range certs {
86
+ serialInt := new (big.Int )
87
+ serialInt .SetString (certRecord .Serial , 10 )
88
+ tempCert := pkix.RevokedCertificate {
89
+ SerialNumber : serialInt ,
90
+ RevocationTime : certRecord .RevokedAt ,
91
+ }
92
+ revokedCerts = append (revokedCerts , tempCert )
93
+ }
94
+
95
+ return CreateGenericCRL (revokedCerts , key , issuerCert , newExpiryTime )
96
+ }
97
+
76
98
// CreateGenericCRL is a helper function that takes in all of the information above, and then calls the createCRL
77
99
// function. This outputs the bytes of the created CRL.
78
100
func CreateGenericCRL (certList []pkix.RevokedCertificate , key crypto.Signer , issuingCert * x509.Certificate , expiryTime time.Time ) ([]byte , error ) {
0 commit comments