LoadLeafCertificates returns the certificates to be loaded by fl.
()
| 62 | |
| 63 | // LoadLeafCertificates returns the certificates to be loaded by fl. |
| 64 | func (fl LeafFileLoader) LoadLeafCertificates() ([]*x509.Certificate, error) { |
| 65 | certificates := make([]*x509.Certificate, 0, len(fl.Files)) |
| 66 | for _, path := range fl.Files { |
| 67 | ders, err := convertPEMFilesToDERBytes(path) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | certs, err := x509.ParseCertificates(ders) |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | certificates = append(certificates, certs...) |
| 76 | } |
| 77 | return certificates, nil |
| 78 | } |
| 79 | |
| 80 | func convertPEMFilesToDERBytes(filename string) ([]byte, error) { |
| 81 | certDataPEM, err := os.ReadFile(filename) |