title: What is the difference between reading a file and pushing a String into a Buffer? - Node
body: <p>I am trying to consume a SSL Certificate in my node app to connect to a db.  When I put the SSL Certificate in a file and read/consume it like this, I am able to connect:</p>
  
  <pre><code>fs.readFile('./cert', (err, caCert) =&gt; {
      const rethink = createRethink({
          servers: [{ host, port }],
          db,
          authKey,
          ssl: { 
              ca: caCert
          } 
      });
      rethink.dbList().run().then(result =&gt; console.log(result));
  });
  </code></pre>
  
  <p>So I read the certificate with <code>fs</code>, and the data that is returned is able to be consumed by my db lib.  </p>
  
  <p>When I try to consume it like this</p>
  
  <pre><code>const rethink = createRethink({
      servers: [{ host, port }],
      db,
      authKey,
      ssl: { 
          ca: new Buffer(caCert, 'utf8')
      } 
  });
  
  rethink.dbList().run().then(result =&gt; console.log(result));
  </code></pre>
  
  <p>The I get this error</p>
  
  <pre><code>Error: unable to verify the first certificate
      at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:1103:38)
      at emitNone (events.js:106:13)
      at TLSSocket.emit (events.js:208:7)
      at TLSSocket._finishInit (_tls_wrap.js:637:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38)
  </code></pre>
  
  <p>I have also tried <code>base64</code> instead of <code>utf8</code>, but that didn't work.  What is the difference between the <code>Buffer</code> and what is read in by the <code>fs</code>?  What am I missing here?</p>