title: Secure exchanges using only socket-io and web client (socket io js)
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>Server side :</p>
  
  <pre><code>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 !")
  })
  </code></pre>
  
  <p>Client side : (I'm using a simple html client)</p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  &lt;script src="socket-io-1-2-1.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      var socket = io.connect('https://localhost:45621', {secure: true})
      socket.on("connect", function() { alert("we are connected to socket io!") })
  &lt;/script&gt;
  </code></pre>
  
  <p>When i'm running my client page, i automatically receive a connection close. (net::ERR_CONNECTION_CLOSED)</p>
  
  <p>It works if i remove the SSL options in server side and change my client connection with :</p>
  
  <pre><code> io.connect("http://localhost:45621")
  </code></pre>
  
  <p>but exchanges aren't secure ?</p>
  
  <p>Edit: Isn't a duplicate of <a href="https://stackoverflow.com/questions/21651133/setup-server-server-ssl-communication-using-socket-io-in-node-js">this</a> because i don't want to use http, https, express by createServer method. I'm only using socket io.</p>