'Crossbar - Using TLS connections with self-signed certificates

I have a WAMP configuration which works flawlessly until I add TLS encryption to communications (following instructions given on docs). Below is my configuration:

{
  "version": 2,
  "controller": {},
  "workers": [
    {
      "type": "router",
      "realms": [
        {
          "name": "realm",
          "roles": [
            {
              "name": "anonymous",
              "permissions": [
                {
                  "uri": "",
                  "match": "prefix",
                  "allow": {
                    "register": true,
                    "publish": true,
                    "call": true,
                    "subscribe": true
                  },
                  "cache": true
                }
              ]
            }
          ]
        }
      ],
      "transports": [
        {
          "type": "websocket",
          "endpoint": {
            "type": "tcp",
            "port": 8080,
            "tls": {
              "key": "MyKey.key",
              "certificate": "MyCertificate.crt"
            }
          },
          "url": "wss://localhost:8080/ws"
        }
      ]
    }
  ]
}

As said, it works fine when not using TLS. However, when I add encryption and try to connect to wss://localhost:8080/ws, I keep getting

connection closed unreachable

The certificate has been generated with OpenSSL (again, as per docs) and Docker is exposing ports. I've been trying to find solutions around but docs are not so explicative, examples on the repo are not working either and I'm out of ideas. Tried to connect to ws:// and it raises an SSL error:

SSL error: http request (in ssl3_get_record)

The code to connect from client is

const autobahn = require('autobahn');

const connection = new autobahn.Connection({
  url: `wss://localhost:8080/ws`,
  realm: 'realm'
});

connection.onopen = () => {
  console.log('Connected');
};

connection.open();

There are no meaningful errors in logs, the only one related to TLS is a warning saying DH ciphers will not be active (because I'm not providing DH parameters). Any idea? Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source