@@ -514,24 +514,24 @@ func (a *Authority) revokeSSH(crt *ssh.Certificate, rci *db.RevokedCertificateIn
514
514
// a new CRL on demand if it has expired (or a CRL does not already exist).
515
515
//
516
516
// force set to true will force regeneration of the CRL regardless of whether it has actually expired
517
- func (a * Authority ) GenerateCertificateRevocationList (force bool ) (string , error ) {
517
+ func (a * Authority ) GenerateCertificateRevocationList (force bool ) ([] byte , error ) {
518
518
519
519
// check for an existing CRL in the database, and return that if its valid
520
520
crlInfo , err := a .db .GetCRL ()
521
521
522
522
if err != nil {
523
- return "" , err
523
+ return nil , err
524
524
}
525
525
526
526
if ! force && crlInfo != nil && crlInfo .ExpiresAt .After (time .Now ().UTC ()) {
527
- return crlInfo .PEM , nil
527
+ return crlInfo .DER , nil
528
528
}
529
529
530
530
// some CAS may not implement the CRLGenerator interface, so check before we proceed
531
531
caCRLGenerator , ok := a .x509CAService .(casapi.CertificateAuthorityCRLGenerator )
532
532
533
533
if ! ok {
534
- return "" , errors .Errorf ("CRL Generator not implemented" )
534
+ return nil , errors .Errorf ("CRL Generator not implemented" )
535
535
}
536
536
537
537
revokedList , err := a .db .GetRevokedCertificates ()
@@ -574,28 +574,24 @@ func (a *Authority) GenerateCertificateRevocationList(force bool) (string, error
574
574
575
575
certificateRevocationList , err := caCRLGenerator .CreateCertificateRevocationList (& revocationList )
576
576
if err != nil {
577
- return "" , err
577
+ return nil , err
578
578
}
579
579
580
- // Quick and dirty PEM encoding
581
- // TODO: clean this up
582
- pemCRL := fmt .Sprintf ("-----BEGIN X509 CRL-----\n %s\n -----END X509 CRL-----\n " , base64 .StdEncoding .EncodeToString (certificateRevocationList ))
583
-
584
580
// Create a new db.CertificateRevocationListInfo, which stores the new Number we just generated, the
585
581
// expiry time, and the byte-encoded CRL - then store it in the DB
586
582
newCRLInfo := db.CertificateRevocationListInfo {
587
583
Number : n ,
588
584
ExpiresAt : revocationList .NextUpdate ,
589
- PEM : pemCRL ,
585
+ DER : certificateRevocationList ,
590
586
}
591
587
592
588
err = a .db .StoreCRL (& newCRLInfo )
593
589
if err != nil {
594
- return "" , err
590
+ return nil , err
595
591
}
596
592
597
593
// Finally, return our CRL PEM
598
- return pemCRL , nil
594
+ return certificateRevocationList , nil
599
595
}
600
596
601
597
// GetTLSCertificate creates a new leaf certificate to be used by the CA HTTPS server.
0 commit comments