OpenSSL cannot read my certificate: PEM routines, no start line
error:0909006C:PEM routines:get_name:no start lineShort answer
OpenSSL looked for a PEM block of one type and did not find it. The file is usually binary DER, not text, or its BEGIN line names another type or is malformed. Check the first line of the file. Convert DER with -inform DER, or fix the BEGIN and END lines.
Fix it fast
1Find out which cause you have
Look at the first line of the file. A PEM certificate starts with a line of text; a DER file is binary and prints garbage.
head -c 80 server.cer; echo2Match what you see, then jump to its fix
- 1
The first line is unreadable binary characters, typical for .cer or .der files exported from Windows or a browser.The file is DER (binary), not PEMFix - 2
The file is text, but the label after BEGIN is not CERTIFICATE (for example a private key given to a certificate command), or the dashes or spacing are damaged.The BEGIN line is wrong for the object the command expectsFix
- 1
What does the error look like?
error:0909006C:PEM routines:get_name:no start lineExpecting: TRUSTED CERTIFICATEPEM_read_bio:no start line
Cause 1 of 2
The file is DER (binary), not PEM
1Check
DER is a binary encoding, while PEM is base-64 text between marker lines. Try reading the file as DER.
openssl x509 -inform DER -in server.cer -noout -subject2Fix
Convert it to PEM and use the converted file everywhere.
openssl x509 -inform DER -in server.cer -outform PEM -out server.pem3Verify
The PEM file now starts with a BEGIN CERTIFICATE line and prints its details.
head -n 1 server.pem
openssl x509 -in server.pem -noout -subject -datesConfirmed by docs.openssl.org
Cause 2 of 2
The BEGIN line is wrong for the object the command expects
1Check
A PEM block is delimited by lines with exactly five hyphens, the label in capitals and one space after BEGIN or END. The label must match the object the command wants. Text before the BEGIN line is ignored, so only the lines themselves matter.
grep -n -E "^-----(BEGIN|END)" server.pem2Fix
Use the file that holds the certificate, or repair the marker lines so they read exactly BEGIN CERTIFICATE and END CERTIFICATE with five hyphens each. Pasting through an editor that trims or wraps lines is a common way to damage them.
-----BEGIN CERTIFICATE-----
(base-64 lines)
-----END CERTIFICATE-----3Verify
OpenSSL parses the file and prints the subject.
openssl x509 -in server.pem -noout -subjectConfirmed by rfc-editor.org
How do I stop it coming back?
- Name files by format when you export them: .pem for text, .der for binary.
- Move certificates between machines as files, not by pasting them into chat or e-mail clients that rewrap lines.
- Run openssl x509 -noout -subject on a certificate as soon as you receive it.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Security
AuthenticationException: your certificate validation callback returned false
System.Security.Authentication.AuthenticationException
This message means a validation callback was installed, yours or one a library added, and it returned false.
3 causes, each with a fixSecurity
SSH to an EC2 instance fails with Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
ec2-user@ec2-203-0-113-25.compute-1.amazonaws.com: Permission denied (publickey).
On EC2 this error almost always means the instance did not accept your key for that user.
3 causes, each with a fixSecurity
gcloud init cannot finish the sign-in step
Enter authorization code
gcloud init signs in through a browser.
3 causes, each with a fixSecurity
A GitHub Actions SSH deploy step cannot log in to the server
ssh: handshake failed: ssh: unable to authenticate
The runner reached your server but the server refused the login.
4 causes, each with a fixSecurity
SSH to GitHub asks to confirm the host, or hangs on that prompt
ED25519 key fingerprint is SHA256:
SSH has never seen github.com from this machine, so it asks you to trust the server key.
2 causes, each with a fixSecurity
A GUI program over SSH says it cannot open the display
cannot open display:
ssh must forward X11 and the remote sshd must allow it.
3 causes, each with a fix