title: Setting up an StartSSL certificate on an Express app
body: <p>I'm learning how to use HTTPS on Express, using as example, a certificate that I generated at StartSSL. I tried taking a look at other solutions over there, but nothing seems to work for me.</p>
  
  <p>Ok, so I generated a .pem file in StartSSL, with a key I saved here. I've put the .pem file in the Express app folder, and I'm trying to set up a working server with this code:</p>
  
  <pre><code>const app = require('express')();
  const fs = require('fs');
  const https = require('https');
  
  // Setup HTTPS
  const httpsPort = 3443;
  const options = {
    key: "my key in plain text",
    cert: fs.readFileSync("./cert.pem")
  };
  var secureServer = https.createServer(options, app).listen(httpsPort, () =&gt; {
      console.log("&gt;&gt; App listening at port "+httpsPort);
  });
  </code></pre>
  
  <p>I also tried with .crt certificate and so, but nothing seems to work. It throws the following error:</p>
  
  <pre><code> C:\some\path\test&gt;node index.js
   _tls_common.js:85
         c.context.setKey(options.key, options.passphrase);
                   ^
  
   Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
       at Error (native)
       at Object.createSecureContext (_tls_common.js:85:17)
       at Server (_tls_wrap.js:776:25)
       at new Server (https.js:26:14)
       at Object.exports.createServer (https.js:47:10)
       at Object.&lt;anonymous&gt; (C:\some\path\test\index.js:18:26)
       at Module._compile (module.js:570:32)
       at Object.Module._extensions..js (module.js:579:10)
       at Module.load (module.js:487:32)
       at tryModuleLoad (module.js:446:12)
  </code></pre>
  
  <p>What am I doing wrong, guys? Thank you!</p>
  
  <p>EDIT:</p>
  
  <p>Also tried putting the password in a .pem file with the following content:</p>
  
  <pre><code>-----BEGIN PRIVATE KEY-----
  (my key)
  -----END PRIVATE KEY-----
  </code></pre>
  
  <p>Which throws another error, maybe more fs-related:</p>
  
  <pre><code>Error: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode
  </code></pre>