title: Setting up SSL with node.js
body: <p>I bought an SSL certificate at GoDaddy and I'm using the following node.js server to attempt to set it up:</p>
  
  <pre><code>var https = require('https'),      // module for https
      fs =    require('fs');         // required to read certs and keys
  
  var options = {
      key: fs.readFileSync('../../ssl/example.com.key'),
      cert: fs.readFileSync('../../ssl/example.com.crt'),
      ca: fs.readFileSync('../../ssl/gd_bundle.crt'),
      requestCert:        true,
      rejectUnauthorized: false
  };
  
  https.createServer(options, function (req, res) {
      if (req.client.authorized) {
          res.writeHead(200, {"Content-Type": "application/json"});
          res.end('{"status":"approved"}');
      } else {
          res.writeHead(401, {"Content-Type": "application/json"});
          res.end('{"status":"denied"}');
      }
  }).listen(443);
  </code></pre>
  
  <p>After running the server, I attempted to visit the website at <a href="https://example.com" rel="nofollow">https://example.com</a> and I just get </p>
  
  <pre><code>{"status":"denied"}
  </code></pre>
  
  <p>I guess this is working properly since I'm getting a response, but I think my understanding of how SSL works is wrong.  I thought the browser gets the certificate from the server, which then authenticates it against root certs, i.e. from GoDaddy.  so shouldn't i get </p>
  
  <pre><code>{"status":"approved"}
  </code></pre>
  
  <p>just simply visiting <a href="https://example.com" rel="nofollow">https://example.com</a> ?</p>
  
  <p>So I guess my question is, how do I visit <a href="https://example.com" rel="nofollow">https://example.com</a> and get {"status":"approved"}? </p>
  
  <p>Thanks!</p>