title: Set accepted CA list and ignore SSL errors with chai-http
body: <p>I'm trying to write unit tests for my node code with chai/chai-http.  Everything was working fine until I switched my server to an HTTPS server, but because my certificate is signed by an internal company root and the common name of the certificate I'm using doesn't match localhost, chai is throwing an error on my request.</p>
  
  <p>I'd like to do the following:</p>
  
  <ol>
  <li><p>Ignore SSL errors related to domain name verification.</p></li>
  <li><p>Set the list of CAs to check against.  If this cannot be done, I'd be fine with just skipping all client-side certificate checks instead.</p></li>
  </ol>
  
  <p>My code is as follows:</p>
  
  <pre><code>var chai = require('chai');
  var chaiHttp = require('chai-http');
  var https = require('https');
  var fs = require('fs');
  var server = require('../app.js');
  
  chai.should();
  chai.use(chaiHttp);
  
  https.globalAgent.options.ca = [
      fs.readFileSync('./ssl/Root.cer'),
  ];
  
  describe('Attachments', function () {
    it('should succeed when passed valid arguments', function (done) {
        chai.request(server)
          .get('/10881057300D0A4E8E8586542AA3626E41')
          .set('userId', 'user')
          .set('region', 'US')
          .end(function (err, res) {
              chai.assert(res);
              res.should.have.status(200);
              chai.assert(res.body);
              done();
          });
    });
  
    it('should return error without userId header', function (done) {
        chai.request(server)
          .get('/10881057300D0A4E8E8586542AA3626E41')
          .end(function (err, res) {
              chai.assert(res);
              res.should.have.status(500);
              chai.assert(res.type == 'application/json');
              done();
          });
    });
  });
  </code></pre>
  
  <p>And I get the following stack trace:</p>
  
  <pre><code> Uncaught AssertionError: Unspecified AssertionError
    at test\test.js:21:18
    at Test.Request.callback (node_modules\superagent\lib\node\index.js:615:12
  )
    at ClientRequest.&lt;anonymous&gt; (node_modules\superagent\lib\node\index.js:56
  7:10)
    at TLSSocket.socketErrorListener (_http_client.js:267:9)
    at emitErrorNT (net.js:1253:8)
  </code></pre>