nginx SSL PEM_read_bio:bad end line

Installing the intermediate certificates on our server gave me the following error while trying to start up nginx again:

The end of the file looked fine, but the problem was half way through it. Somehow the concatenation had joined two lines together:

This just needed a line break to fix:

  • Gary

    Yay – that one bugged me too

  • Hagsteel

    Good spot!
    Had the same issue just now and this post saved me a bundle.
    Thanks

  • It solved my problem as well. Thanks!

  • thanks! solved my problem

  • running

    thanks solved my problem as well. I used startssl certs

  • Cabeza

    Do not ever remove this post! It is good as new. Thanks

  • Rich

    Perfect – thank you!

    I was also using startssl.

  • Daniel Winter

    oh my god. thanks!

  • Ced

    Great, thank you, you saved my day !

  • Ishibu

    Thanks !!!

  • inhji

    Very helpful. Thanks!

  • André Breitfeld

    Thank sooo much, you did it^^

  • Dan

    Saved me a lot of time that could be wasted because i did the same with one BIG mistake, somehow i thought that:

    —–END CERTIFICATE—–
    —-BEGIN CERTIFICATE—–

    Should be (*another ‘-‘ after END CERTIFICATE…):

    —–END CERTIFICATE——
    —-BEGIN CERTIFICATE—–

    The first one is correct BTW as it says in the post.

  • Thank you so much!! I was about to give up and move back to Apache before I found this post.

  • Android Code Geeks

    Great thanks , really helpful

  • Ninad

    wow, what a silly mistake :( 1 post and it was spot on …

  • Ulysses Alexandre Alves

    Thank you. This is exactly what was happening. Fixed it and my server is running smoth again.

  • David Thornley

    For me this was more sinister, using cat on files of which one is CRLF and the other has LF linefeeds causes the line ending problem described above. You should sanitise the certificates first with dos2unix and then use cat, it will save you a lot of time.

  • Dong-in Yim

    Thanks^^