nginx config fails with SSL key/pem (unique case)

I am trying to install SSL on my nginx reverse proxy with certified ssl keys but i get this message when i try to restart server:

Restarting nginx: [emerg]: SSL_CTX_use_PrivateKey_file("/etc/nginx/conf.d/cert.key") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib)
configuration file /etc/nginx/nginx.conf test failed

everyfiles are root:root with 600 permissions i've tested the certificats and they are validated with this website: http://ssltools.com/cert_key_match

there are no trailing weird caracters in my keys, and has 64 caracter per line

here is my config file

server {
    listen   443;
    server_name     my.domain.com;
    ssl on;
    ssl_certificate      conf.d/cert.pem;
    ssl_certificate_key  conf.d/cert.key;

    location / {
         proxy_pass         http://upstream1;
         proxy_redirect     off;
         proxy_buffering    off;
         proxy_set_header        Host            $host;
         proxy_set_header        X-Real-IP       $remote_addr;
         proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

Any ideas? Thank you


Solution 1:

check here

I hope you've copy-pasted with the following lines:

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

Solution 2:

A different solution that may work for others:

use the .pem file for both ssl_certificate and ssl_certificate_key

That is:

...
ssl on;
ssl_certificate      conf.d/cert.pem;
ssl_certificate_key  conf.d/cert.pem;
...