Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get https running #11158

Open
frameworker2019 opened this issue Jun 30, 2021 · 4 comments
Open

Can't get https running #11158

frameworker2019 opened this issue Jun 30, 2021 · 4 comments

Comments

@frameworker2019
Copy link

There's an .env file with following content in the root directory of the react app:

HTTPS=true
SSL_CRT_FILE=/ssl/certificate.crt
SSL_KEY_FILE=/ssl/certificate.key
 /app/myProjectPath:
  total used in directory 484 available 1731267132
  drwxrwxrwx  1 user Domänen-Benutzer   8192 06-16 19:17 ..
  drwxrwxrwx  1 user Domänen-Benutzer   4096 06-21 10:59 .
  -rw-rw-rw-  1 user Domänen-Benutzer     82 06-22 17:18 .env
  drwxrwxrwx  1 user Domänen-Benutzer   4096 06-21 10:59 .git
  -rw-rw-rw-  1 user Domänen-Benutzer    324 2020-06-20  .gitignore
  -rw-rw-rw-  1 user Domänen-Benutzer   1067 06-21 10:56 node_modules
  -rw-rw-rw-  1 user Domänen-Benutzer    759 06-21 10:59 package.json
  -rw-rw-rw-  1 user Domänen-Benutzer    753 06-16 19:28 package.json.bkp
  -rw-rw-rw-  1 user Domänen-Benutzer    176 2020-11-12  post.sh
  drwxrwxrwx  1 user Domänen-Benutzer   4096 06-16 19:17 public
  -rw-rw-rw-  1 user Domänen-Benutzer   9830 06-16 19:17 README.md
  drwxrwxrwx  1 user Domänen-Benutzer   4096 06-16 19:17 src
  -rw-rw-rw-  1 user Domänen-Benutzer 457759 2020-06-20  yarn.lock

When the server starts, I've got the output:

> react-template@0.1.0 start /app/myProjectPath

> react-scripts start

certificate.crt file exists.

certificate.key file exists.

Starting the development server...

Compiled successfully!

You can now view react-template in the browser.

https://localhost:3000/

Note that the development build is not optimized.

To create a production build, use yarn build.

To ensure that both the certificate and key file can be read by node.js, I've added some debug code inside start.js:

if(fs.existsSync('/ssl/certificate.crt')) {
	          console.log("certificate.crt file exists.");
} else {
                  console.log('certificate.crt file does not exist.');
}

if(fs.existsSync('/ssl/certificate.key')) {
	          console.log("certificate.key file exists.");
} else {
                  console.log('certificate.key file does not exist.');
}

As you can see in the output above, both files could be read at startup.

If I call https://localhost:3000 I've got different browser error messages:

Firefox 89: SEC_ERROR_INADEQUATE_KEY_USAGE

Chrome 88: NET::ERR_CERT_AUTHORITY_INVALID

The same key and certificate files are working well in a simple Apache https config, so I assume the certificate and its key are issued correctly.
So what's wrong with node.js https development server here?

@noknokcody
Copy link

Same issue as OP. SSL_CRT_FILE AND SSL_KEY_FILE aren't loading the certificate correctly for me either

@noknokcody
Copy link

noknokcody commented Oct 20, 2021

I was able to resolve my problem using react-scripts@3.4.2 and the following environment variables
.env.development

HTTPS=true
HOST=app.myserver.local
SSL_CRT_FILE=.cert/server.crt
SSL_KEY_FILE=.cert/server.key
HTTPS_CERT=.cert/server.crt
HTTPS_KEY=.cert/server.key

I don't know if this helps your issue but if not try looking here

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 9, 2022
@mypherhistamine
Copy link

Any fixes ?

@stale stale bot removed the stale label Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants