1

I have a .crt, .key and CA.pem files that were generated like this.

These certs are kind of project-wide, and they work when firing up a webpack-dev-server server on HTTPS like:

devServer: {
  https: {
    key: fs.readFileSync('/path/to/example.com.key'),
    cert: fs.readFileSync('/path/to/examle.com.crt'),
    ca: fs.readFileSync('/path/to/CA.pem'),
  }
}

Now I need to setup an Nginx server using these 3 files, but I've been trying with no luck. Here's my config:

server {
    listen       3000;

    ssl_certificate certs/example.com.crt;
    ssl_certificate_key certs/example.com.key;

    # where does the CA.pem file go??
}

The result of this is Chrome giving me a

This site can’t provide a secure connection 
example.com sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

Nginx logs show random hex characters:

172.18.0.1 - - [14/Dec/2018:18:01:55 +0000] "\x16\x03\x01\x00\xDD\x01\x00\x00\xD9\x03\x03\xAB\xE1\xB3\x1F\xCE\x02\x02\xC5}q\xDFgd\xF1`\xC1m\x8E\x99\xCE' \x98\xDF\xDEEg\x8Fm\xED\x9F\xB1\x00\x00\x1C" 400 166 "-" "-" "-" 0.001 -

Any ideas what could I be doing wrong?

CC BY-SA 4.0

1 Answer 1

4

You need to concatenate your certificate with CA for nginx:

cp example.com.crt example.com.fullchain.pem
cat CA.pem >> example.com.fullchain.pem

and use this file in nginx config:

ssl_certificate certs/example.com.fullchain.pem;
CC BY-SA 4.0
2
  • I actually ended up concatenating only the CA and the crt. But yeah it worked Commented Dec 20, 2018 at 14:01
  • I think that is exactly what I tell you to do, I didn't mention a key file in my answer. Full path of concatenated file goes as ssl_sertificate parameter, full path of key file goes as ssl_certificate_key parameter. FYI, certbot from Let's Encrypt generates all of these files (key as privkey.pem, cert as cert.pem, CA as chain.pem, and concatenated cart+CA as fullchain.pem). Commented Dec 20, 2018 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.