There is an SSL certificate (authentic) and the application on the node:
var fs=require("fs"); var express = require('express'); var https = require('https'); var redis=require("redis"); var client = redis.createClient(); var mysql=require("mysql"); var app = express(); client.on("error", function (err) { console.log("Error " + err); }); var options = { key: fs.readFileSync('ssl/key.pem', 'utf8'), cert: fs.readFileSync('ssl/server.crt', 'utf8') }; var server=https.createServer(options, function(req, res){ console.log("https сервер запущен"); }).listen(9099); var io = require("socket.io")(server);
Tried to run the code, but gave an error: crypto.js:132 if (options.cert) c.context.setCert(options.cert); ^ Error: error:0906D06C:PEM routines:PEM_read_bio:no start line crypto.js:132 if (options.cert) c.context.setCert(options.cert); ^ Error: error:0906D06C:PEM routines:PEM_read_bio:no start line Found a solution through execution:
openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt
And var options = { key: fs.readFileSync('./key.pem', 'utf8'), cert: fs.readFileSync('./server.crt', 'utf8') };
Now everything starts, but it gives a message that the certificate is invalid (you need to confirm the transition action) + you also need to download it to your computer in order for the browser to open. Can anyone come across a similar thing to do?

  • How did you get this certificate? - Mikhail Vaysman
  • It is provided free of charge by a hosting upon purchase of domains - sferos corp
  • what do you want for hoting? Who is their certificate provider? you can get a free certificate from letsencrypt.org - Mikhail Vaysman
  • I do not know, I used nginx for the node and specified certificates in the config without problems. Here there is more of a question of how to correctly form certificates so that they are valid, do not confuse anything - modelfak

0