{"record":{"id":"7613c94839fe9b6d","repo":"caddyserver/caddy","slug":"no-certificate-pem-block-found-in-the-given-pem-da","errorCode":null,"errorMessage":"no CERTIFICATE pem block found in the given pem data","messagePattern":"no CERTIFICATE pem block found in the given pem data","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddytls/leafstorageloader.go","lineNumber":111,"sourceCode":"\t\tders, err := convertPEMToDER(certData)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcerts, err := x509.ParseCertificates(ders)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcertificates = append(certificates, certs...)\n\t}\n\treturn certificates, nil\n}\n\nfunc convertPEMToDER(pemData []byte) ([]byte, error) {\n\tvar ders []byte\n\t// while block is not nil, we have more certificates in the file\n\tfor block, rest := pem.Decode(pemData); block != nil; block, rest = pem.Decode(rest) {\n\t\tif block.Type != \"CERTIFICATE\" {\n\t\t\treturn nil, fmt.Errorf(\"no CERTIFICATE pem block found in the given pem data\")\n\t\t}\n\t\tders = append(\n\t\t\tders,\n\t\t\tblock.Bytes...,\n\t\t)\n\t}\n\t// if we decoded nothing, return an error\n\tif len(ders) == 0 {\n\t\treturn nil, fmt.Errorf(\"no CERTIFICATE pem block found in the given pem data\")\n\t}\n\treturn ders, nil\n}\n\n// Interface guard\nvar (\n\t_ LeafCertificateLoader = (*LeafStorageLoader)(nil)\n\t_ caddy.Provisioner     = (*LeafStorageLoader)(nil)\n)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/leafstorageloader.go#L93-L129","documentation":"Error \"no CERTIFICATE pem block found in the given pem data\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/caddytls/leafstorageloader.go:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the stored PEM data contains a CERTIFICATE block at the expected storage key."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}