Last active
August 16, 2020 13:47
-
-
Save rezonn/47433d7d141a20d7e15c5929ae474731 to your computer and use it in GitHub Desktop.
https server nodes openssl
This file contains hidden or 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
| cd "${0%/*}" | |
| cat > "app.js" <<- EOM | |
| const https = require('https'); | |
| const fs = require('fs'); | |
| const options = { | |
| key: fs.readFileSync('key.pem'), | |
| cert: fs.readFileSync('cert.pem') | |
| }; | |
| https.createServer(options, function (req, res) { | |
| res.writeHead(200); | |
| res.end(fs.readFileSync('index.html')); | |
| }).listen(8000); | |
| EOM | |
| cat > "index.html" <<- EOM | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <p>hello world</p> | |
| EOM | |
| openssl genrsa -out key.pem | |
| printf '%s\n' en en en en en en en enen | openssl req -new -key key.pem -out csr.pem | |
| openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem | |
| open 'https://localhost:8000' | node app.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment