Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
1  
Are you using a chained certificate? If so, you should follow the instructions at the certificate authority. You need to include the chained certificate as well. Alsom, I strongly discourage you from uploading your certificates to a random website. If they're saving what's uploaded your cert has already been compromised. You can do the verification with openssl directly yourself. –  yoonix Jan 31 at 19:43
    
yes i am. in my cert.pem i start with the root cert, then in the same file there is the intermediate cert. Now on my cert.key file there is two cert where the second one starts with -----BEGIN RSA PRIVATE KEY----- –  Fredow Feb 3 at 5:15

1 Answer 1

up vote 0 down vote accepted

check here

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

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
share|improve this answer
    
the cert.pem in that exemple acts as ssl_certificate or ssl_certificate_key ? –  Fredow Feb 3 at 5:15
    
extention .pem always acts as certificate. –  Ilja Feb 3 at 8:06
    
Yeah i had it already done. I have 4 keys in those 2 files, ill post the content of my keys here (this formatting is too good...): cert.pem : -----BEGIN CERTIFICATE----- [...] -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- [...] -----END CERTIFICATE----- cert.key -----BEGIN CERTIFICATE----- [...] -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- [...] -----END RSA PRIVATE KEY----- –  Fredow Feb 3 at 14:38
    
cert.key MUST contain only key: -----BEGIN RSA PRIVATE KEY----- [...] -----END RSA PRIVATE KEY----- –  Ilja Feb 3 at 15:51
1  
Ive resolved locally my issue. The formatting of the keys are different with nginx vs apache, and the bundle key has 3 certificats inside it, not two. Thankx for your help IIja, it's much apreciated. –  Fredow Feb 6 at 19:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.