I created a SSL certificate with openssl on a debian 8 VM. So i have a single PEM file which contain my key and my certificate.
I would like to know if it's possible to use a SSL certificate without https, express etc, simply by using a architecture with socket IO (server side) and socket IO client (client side).
Server side :
var fs = require("fs")
, options = {
key : fs.readFileSync('./test/apache.pem'),
cert : fs.readFileSync('./test/apache.pem')
}
var io = require('socket.io').listen(45621, options)
io.sockets.on("connection", function(socket) {
console.log("socket " + socket.id + " connected !")
})
Client side : (I'm using a simple html client)
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="socket-io-1-2-1.js"></script>
<script>
var socket = io.connect('https://localhost:45621', {secure: true})
socket.on("connect", function() { alert("we are connected to socket io!") })
</script>
When i'm running my client page, i automatically receive a connection close. (net::ERR_CONNECTION_CLOSED)
It works if i remove the SSL options in server side and change my client connection with :
io.connect("http://localhost:45621")
but exchanges aren't secure ?
Edit: Isn't a duplicate of this because i don't want to use http, https, express by createServer method. I'm only using socket io.