title: SSL in socket.io with express: Missing PFX or certificate + private key.
body: <p>I want to socket with socket.io through SSL. <strong>I have read the other answers but nothing worked</strong></p>
  
  <p>Here is my code:</p>
  
  <pre><code>var ssl_options = {
      key : fs.readFileSync(my_key_path),
      cert : fs.readFileSync(my_cert_path)
  };
  
  var protocol = "https";
  
  preparedApp = require(protocol).createServer(ssl_options,app);
  
  var io = require('socket.io')(preparedApp);
  
  preparedApp.listen(8080, function(){});
  io.on('connection', function(socket){});
  </code></pre>
  
  <p>And here is the log of my ssl_options...</p>
  
  <pre><code>{ key: &lt;Buffer 41 ...&gt;,
   cert: &lt;Buffer 4a ...&gt; }
  </code></pre>
  
  <p>This errors with the error in the title <code>throw new Error('Missing PFX or certificate + private key.');</code>. Does anyone know what might be happening? None of the other solutions to this answer solved my case.</p>