I need to run local Express server on https protocol. I used instructions from this site and the similar. But when I tried to open the page in browser, I get Your connection is not private error. When I opened Security tab from Developer tools, I saw This site is missing a valid, trusted certificate (net::ERR_CERT_INVALID) error. When I tried to send request via Postman, my server didn't response, and the curl request returns:
curl: (60) SSL certificate problem: unable to get local issuer certificate
Here is server code:
const app = require('express')();
const fs = require('fs');
const https = require('https');
const options = {
  key: fs.readFileSync('./key.pem'),
  cert: fs.readFileSync('./cert.pem')
};
app.get('/', (req, res) => {
  res.send('hello world');
});
https
  .createServer(options, app)
  .listen(3000, '127.0.0.1', () => {
    console.log('Run on: https://127.0.0.1:3000');
  });
I've created certificates with the next command:
$ openssl req -nodes -sha256 -new -x509 -keyout key.pem -out cert.pem -days 365 -config req.cnf
where req.cnf file has the following content:
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = US
ST = VA
L = SomeCity
O = MyCompany
OU = MyDivision
CN = 127.0.0.1:3000
[v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = IP:127.0.0.1:3000
I tried to use 443 port as well, but, unfortunately, I've got the same errors. Also, I tried to open page https://127.0.0.1:3000 with Incognito mode - nothing happened - errors are the same.
My questions are:
- Where am I wrong with creating certificates?
- Why I can't send a request to my server via Postman/curl?
 
    