File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "bytes"
45 "crypto/tls"
56 "crypto/x509"
67 "encoding/pem"
@@ -26,11 +27,21 @@ func loadCrlFromFile(path string) (*x509.RevocationList, error) {
2627 if openCrlError != nil {
2728 return nil , openCrlError
2829 }
29- block , rest := pem .Decode (crlContent )
30- if len (rest ) > 0 {
31- return nil , fmt .Errorf ("failed to decode crl" )
30+
31+ // if the file contains a pem block, decode it
32+ // otherwise, assume it is a DER encoded CRL
33+ crlBlock := & pem.Block {}
34+ if bytes .Contains (crlContent , []byte ("BEGIN" )) {
35+ block , rest := pem .Decode (crlContent )
36+ if len (rest ) > 0 {
37+ return nil , fmt .Errorf ("failed to decode crl" )
38+ }
39+ crlBlock = block
40+ } else {
41+ crlBlock = & pem.Block {Type : "X509 CRL" , Bytes : crlContent }
3242 }
33- crl , parseCrlError := x509 .ParseRevocationList (block .Bytes )
43+
44+ crl , parseCrlError := x509 .ParseRevocationList (crlBlock .Bytes )
3445 if parseCrlError != nil {
3546 return nil , parseCrlError
3647 }
You can’t perform that action at this time.
0 commit comments