Search code examples
nginxsslssl-certificate

NGINX SSL PRIVATE KEY routines:PEM_read_bio:bad end line error:140B0009:SSL


Hello guyz I am trying to renew my ssl certificate in nginx. I did same way earlier and it worked but this time after create bundle.crt and private.key file when I try to restart nginx I am getting this error

nginx: [emerg] SSL_CTX_use_PrivateKey_file("/srv/www/website.yaabi.com/calletest/20242.yaabi.com.key") failed (SSL: error:0906D066:PEM routines:PEM_read_bio:bad end line error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib)

Though my certificate and key are matching and private key format is also exact same

private key

-----BEGIN PRIVATE KEY----- //key -----END PRIVATE KEY-----

AFTER properly checking I was able may be the issue was related to copy paste but now facing this issue. Error Screenshot

I was expecting to work new SSL certificate properly


Solution

  • Thanks to @SteffenUllrich. I was able to resolve by properly copying and pasting without extra lines.

    There is likely something corrupt in the file - only one can not be more specific w/o actually having the file. Common errors: wrong line ends (like CRLF instead of LF), missing characters from cut+paste into a file, wrong encoding (like UTF-16 instead of ASCII/UTF-8), ... Typically these errors happen if the key is somehow created by copy+pasting. –