Skip to content

Instantly share code, notes, and snippets.

@wesdeveloper
Created May 15, 2019 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesdeveloper/45c433cbe78faa676657d0bfebb78c9b to your computer and use it in GitHub Desktop.
Save wesdeveloper/45c433cbe78faa676657d0bfebb78c9b to your computer and use it in GitHub Desktop.
Https server example.
const fs = require("fs");
const https = require("https");
// Carrega o certificado e a key necessários para a configuração.
const options = {
key: fs.readFileSync("server.key"),
cert: fs.readFileSync("server.cert")
};
// Cria a instância do server e escuta na porta 3000
https
.createServer(options, (req, res) => {
res.writeHead(200);
res.end("Hello world using HTTPS!\n");
})
.listen(3000);
// Você pode testar com o curl: curl -k https://localhost:3000
// Retorno --> Hello world using HTTPS!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment