I am running a Node.js server and I'm trying to host this server locally and not get any SSL errors.
Here's what I did to create the certificate. I opened up Terminal in Visual Studio Code and typed the following:
$ openssl req -nodes -new -x509 -keyout server.key -out server.cert
This created a .cert and a .key file in my current directory.
Next, in my app.js file, I added this:
https.createServer({
key: fs.readFileSync('./server.key'),
cert: fs.readFileSync('./server.cert')//,
//passphrase: ''
}, app)
.listen(3000);
I then ran the command node app.js
in my terminal window to start the Node.js server.
I then visited https://localhost:3000/
and am getting the following - notice "Not secure" - this is what I am trying to get rid of:
At this point, I did some Googling and saw where it might be helpful to export this certificate, and import directly into Chrome. I did this by clicking on the "Not secure" button and Click on Certificate:
Then, clicking on Details and "Copy to file":
Then, I clicked Next on the next screen and chose DER encoded binary X.509 (.CER)
:
I clicked Next and gave the exported certificate a name of serverMike.cer:
Then, I clicked Next and Finish:
Export was successful:
Finally, I go to import this exported certificate in Chrome settings and choose "Trusted Root Certification Authorities" as where to place this certificate in:
I then clicked Next and Finish. I closed out of Chrome and opened it back up, visited https://localhost:3000 and receive the same "Not secure" message. Is there something I might be doing wrong?