-
-
Save venescu/dcc00931a0373df38996065c8261366a to your computer and use it in GitHub Desktop.
A simple HTTPS express server.
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
const fs = require( 'fs' ); | |
const https = require( 'https' ); | |
const express = require( 'express' ); | |
// import private key and public certificate | |
const privateKey = fs.readFileSync( './thatisuday.key', 'utf8' ); | |
const certificate = fs.readFileSync( './thatisuday.crt', 'utf8' ); | |
// create an express app | |
const app = express(); | |
app.get( '/', ( _req, res ) => { | |
res.send( "Hello Secure World!" ); | |
} ); | |
// launch HTTPS server on port 443 | |
const credentials = { key: privateKey, cert: certificate }; | |
const httpsServer = https.createServer( credentials, app ); | |
httpsServer.listen( 443 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment