Created
May 15, 2019 22:53
-
-
Save wesdeveloper/45c433cbe78faa676657d0bfebb78c9b to your computer and use it in GitHub Desktop.
Https server example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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