goharbor/harbor · error

failed to parse certificate

Error message

failed to parse certificate: %v

What it means

Parse error in parseCertificatesFromPEM: a PEM block typed CERTIFICATE was found but x509.ParseCertificate rejected its DER bytes. %v carries the x509 error; it fires on malformed/unsupported certificate data embedded in an otherwise valid PEM envelope.

Solutions

  1. Regenerate or re-export the certificate — the DER payload is malformed
  2. Verify the certificate is not truncated or base64-corrupted
  3. Ensure the file contains actual certificates, not keys or CSRs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/common/http/transport.go:148 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/0a65f95ec2493d31. Report an issue: GitHub.

Appendix: source

Thrown at src/common/http/transport.go:148

func parseCertificatesFromPEM(pemData string) ([]*x509.Certificate, error) {
	var certs []*x509.Certificate
	rest := []byte(pemData)

	for {
		var block *pem.Block
		block, rest = pem.Decode(rest)
		if block == nil {
			break
		}
		if block.Type != "CERTIFICATE" {
			continue
		}

		cert, err := x509.ParseCertificate(block.Bytes)
		if err != nil {
			return nil, fmt.Errorf("failed to parse certificate: %v", err)
		}

		certs = append(certs, cert)
	}

View on GitHub (pinned to 7b2fd08cc5)