Search code examples
httpsssl-certificatecreate-react-app

create-react-app: how to use https but with signed cert?


I've seen the quite useful answer here: create-react-app: how to use https instead of http?

BUT

I'm not sure of the details on how to get this to work with a properly signed SSL cert.

Which version/format of the cert should I be using? PEM, or DER

I've seen some mention that you need to somehow combine the Issuing CA.cer and Root CA.cer (which I also have) into the PEM file. Is this correct?

Also, I'm using yarn and not npm, trying to use the following:

HTTPS=true SSL_CRT_FILE=QA_SSL_Cert.cer SSL_KEY_FILE=server.key yarn react-scripts start

The server starts, but I get the NET::ERR_CERT_AUTHORITY_INVALID error when I try to connect. (Without enabling HTTPS=true the app itself runs just fine.)


Solution

  • What you are doing is essentially correct. It seems that you are missing your chain of trust (probably because you haven't combined the Issuing CA.cer and Root CA.cer).

    What you need to do is take the text from your signed SSL certificate, and append Issuing CA.cer and Root CA.cer, in that order, to the bottom.

    Example (Chain certificate):

    My SSL Certificate

    Intermediate SSL Certificate (Issuing CA)

    Root SSL Certificate (Root CA)

    Each of the lines should be one after the other on separate lines (no empty lines between them).