testing local https server with mocha/superagent

So I see there was a pull request a few months ago for superagent to allow you to specify the CA in a request. It does not appear that the docs were updated to reflect this change, so I can't seem to figure out how to do it.

I am trying to test on my local machine a REST service which exposes both http and https endpoints. All the http ones work fine, the SSL ones....well.....not so much.

After spending all day yesterday running down certificate errors, I am 90% certain I have the server working correctly. Curl seems to think so, as does a vanilla node request object.

I assume superagent is probably creating a request under the hood - I just need to know how to pass in the CA for it.

Thanks in advance.

There is a usage example in their tests.

Basically:

var https = require('https'),
    fs = require('fs'),
    key = fs.readFileSync(__dirname + 'key.pem'),
    cert = fs.readFileSync(__dirname + 'cert.pem'),
    assert = require('better-assert'),
    express = require('express'),
    app = express();

app.get('/', function(req, res) {
    res.send('Safe and secure!');
});

var server = https.createServer({
    key: key,
    cert: cert
}, app);

server.listen(8443);

describe('request', function() {
    it('should give a good response', function(done) {
        request
            .get('https://localhost:8443/')
            .ca(cert)
            .end(function(res) {
                assert(res.ok);
                assert('Safe and secure!' === res.text);
                done();
            });
    });
});