(filename string)
| 753 | } |
| 754 | |
| 755 | func convertPEMFilesToDER(filename string) ([]string, error) { |
| 756 | certDataPEM, err := os.ReadFile(filename) |
| 757 | if err != nil { |
| 758 | return nil, err |
| 759 | } |
| 760 | var ders []string |
| 761 | // while block is not nil, we have more certificates in the file |
| 762 | for block, rest := pem.Decode(certDataPEM); block != nil; block, rest = pem.Decode(rest) { |
| 763 | if block.Type != "CERTIFICATE" { |
| 764 | return nil, fmt.Errorf("no CERTIFICATE pem block found in %s", filename) |
| 765 | } |
| 766 | ders = append( |
| 767 | ders, |
| 768 | base64.StdEncoding.EncodeToString(block.Bytes), |
| 769 | ) |
| 770 | } |
| 771 | // if we decoded nothing, return an error |
| 772 | if len(ders) == 0 { |
| 773 | return nil, fmt.Errorf("no CERTIFICATE pem block found in %s", filename) |
| 774 | } |
| 775 | return ders, nil |
| 776 | } |
| 777 | |
| 778 | func (clientauth *ClientAuthentication) provision(ctx caddy.Context) error { |
| 779 | if len(clientauth.CARaw) > 0 && (len(clientauth.TrustedCACerts) > 0 || len(clientauth.TrustedCACertPEMFiles) > 0) { |
no test coverage detected