fix: enhance error handling in ConvertPEMToPFX for empty certificate cases

This commit is contained in:
GitHub Actions
2026-04-13 14:11:48 +00:00
parent 29c56ab283
commit 7c8e8c001c

View File

@@ -340,9 +340,12 @@ func ConvertPFXToPEM(pfxData []byte, password string) (certPEM string, keyPEM st
// ConvertPEMToPFX bundles cert, key, chain into PFX.
func ConvertPEMToPFX(certPEM string, keyPEM string, chainPEM string, password string) ([]byte, error) {
certs, err := parsePEMCertificates([]byte(certPEM))
if err != nil || len(certs) == 0 {
if err != nil {
return nil, fmt.Errorf("failed to parse cert PEM: %w", err)
}
if len(certs) == 0 {
return nil, fmt.Errorf("no certificates found in cert PEM")
}
key, err := parsePEMPrivateKey([]byte(keyPEM))
if err != nil {