3

Everything works just fine with out the ssl connection.

The response I get back after how I set it up:
socket.io-1.4.5.js:1
GET https://domain.com:3000/socket.io/?EIO=3&transport=polling&t=LILwU3l net::ERR_INSECURE_RESPONSE


Server

node.js v.6.1

package.json

{
  //...,
  "dependencies":
  {
    "socket.io": "1.4.5"
  }
}

server.js

Looking at how socket.io solves creating a server if only a port is declared: https://github.com/socketio/socket.io/blob/master/lib/index.js#L212

const
  fs      = require('fs'),
  https   = require('https').createServer(
    {
      // certificate by godaddy (G2)
      key : fs.readFileSync('/etc/ssl/private/domain.key'),
      cert: fs.readFileSync('/etc/ssl/certs/domain.crt')
    },
    (req, res) =>
    {
      res.writeHead(404);
      res.end();
    }).listen(3000),
  io      = require('socket.io')(https);

io.on('connection', (socket) => {console.log('CONNECTED');});

Client

require.config(
{
  shim:
  {
    'socketio':
    {
      exports: 'io'
    }
  },
  paths:
  {
    socketio: 'https://cdn.socket.io/socket.io-1.4.5'
  }
});

define(['socketio'], function(io)
{
  var socket = io.connect('https://domain.com:3000');
});

SSL verification

$ openssl s_client -CApath /etc/ssl/certs/ -connect domain.com:3000 -showcerts
...
Verify return code: 0 (ok)
Community
  • 1
  • 1
superhero
  • 6,281
  • 11
  • 59
  • 91
  • Tried adding the `secure:true` option as described here: http://stackoverflow.com/a/6601067/570796, no luck! – superhero May 09 '16 at 15:08
  • you can test it with ssllabs.com (but I think you need to use the port 443). – Tom May 09 '16 at 16:45
  • it's in a local environment @Tom, just altered the `/etc/hosts` – superhero May 09 '16 at 17:42
  • in the end I solved this by creating my own websocket... not saying it can't be done with socket.io, I just had enough of all the little quirks I kept running into and that I couldn't properly debug. For inspiration or use by others: https://www.npmjs.com/package/@superhero/websocket – superhero Sep 14 '16 at 13:33

0 Answers0