Error message
error:0480006C:PEM routines::no start line
Reproduced on Node 26 (OpenSSL 3.5) with X509Certificate and tls.createSecureContext(). OpenSSL 1.1.1 prints the same failure as "error:0909006C:PEM routines:get_name:no start line", OpenSSL 1.1.0 as "error:0906D06C:PEM routines:PEM_read_bio:no start line". A related sibling: "error:04800066:PEM routines::bad end line" when the END marker is damaged.
OpenSSL 3.x — also surfaces in Node as ERR_OSSL_PEM_NO_START_LINE
What it means
A PEM parser scanned the input for a "-----BEGIN ...-----" line matching the object it expects and never found one. Either the file is not PEM at all (binary DER, JSON, empty), or the BEGIN label names a different object than the parser wants, or the framing was mangled on the way.
Why it happens
DER (binary) data fed to a PEM parser
common.der/.cer/.pfx files are binary; they contain no BEGIN line by definition. Loaders that only read PEM — tls.createSecureContext() for a certificate, the OpenSSL 1.1 command line — land exactly here. (Node's X509Certificate and OpenSSL 3 commands detect DER on their own.)
Label mismatch: right file, wrong object
commonParsers look for their own label. Code reading certificates skips "-----BEGIN PRIVATE KEY-----" blocks entirely and reports no start line — technically true: no CERTIFICATE start line exists.
Framing broken by transport
commonLiteral \n sequences from env vars/JSON, or look-alike dashes pasted from a document editor, prevent the BEGIN match. A UTF-8 BOM before the first dash breaks OpenSSL 1.1 (OpenSSL 3 and Node skip it); Windows CRLF line endings and a missing final newline are tolerated.
How to fix it
- 1.
Look at the first bytes
One xxd line distinguishes PEM (ASCII dashes), DER (0x30 first byte) and garbage. Then convert or fix accordingly.
bash head -c 32 file | xxd # 2d 2d 2d 2d 2d ("-----") → PEM: check the label matches what the tool expects # 30 82 ... → DER: add -inform der or convert: openssl x509 -inform der -in cert.der -out cert.pem - 2.
Repair transport-mangled PEM
Restore newlines and strip BOM/CR. After repair the BEGIN line must be exactly five dashes, the label, five dashes.
bash printf '%s' "$PEM_VAR" | sed 's/\\n/\n/g' | sed '1s/^\xef\xbb\xbf//' | tr -d '\r' > fixed.pem head -1 fixed.pem # -----BEGIN CERTIFICATE----- - 3.
In Node, normalize before parsing
The same error appears as code ERR_OSSL_PEM_NO_START_LINE from X509Certificate and from the cert option of tls.createSecureContext(); the env-var newline fix solves most cases. Key loaders (createPublicKey, createPrivateKey) report unparseable input as "error:1E08010C:DECODER routines::unsupported" instead.
js import { X509Certificate } from "node:crypto"; const cert = new X509Certificate(process.env.CERT_PEM.replace(/\\n/g, "\n"));