Last active
December 19, 2015 14:49
-
-
Save caok/5972114 to your computer and use it in GitHub Desktop.
Node.js, Socket.io And SSL
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
// Load libraries | |
var https = require('https'); | |
var fs = require('fs'); | |
var socketio = require('socket.io'); | |
// The server options | |
var svrPort = 8888; // This is the port of service | |
var svrOptions = { | |
key: fs.readFileSync('certs/server.key'), | |
cert: fs.readFileSync('certs/server.crt'), | |
ca: fs.readFileSync( 'bundle.crt') | |
}; | |
// Create a Basic server and response | |
var servidor = https.createServer( svrOptions , function( req , res ){ | |
res.writeHead(200); | |
res.end('Hi! Code here...'); | |
}); | |
// Create the Socket.io Server over the HTTPS Server | |
io = socketio.listen( servidor ); | |
// Now listen in the specified Port | |
servidor.listen( svrPort ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment