...
En algunos casos, además de instalar el certificado proporcionado a través de PillínPiolín, es necesario instalar el certificado raíz o el certificado intermedio.
...
El siguiente código establece un servidor https en nodejs;
| Bloque de código | ||
|---|---|---|
| ||
#vim https_server.js
var https = require('https');
var fs = require('fs');
var https_options = {
key: fs.readFileSync("/path/to/certificado.key"),
cert: fs.readFileSync("/path/to/certificado.pem"),
ca: [
fs.readFileSync('path/to/cadena.pem')
]
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("Welcome to Node.js HTTPS Servern");
}).listen(443) |