ssl-root-cas.js/test.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-10-20 18:39:05 +00:00
'use strict';
testDefault();
// backwards compat
function testDefault() {
require('https').globalAgent.options.ca = null;
var rootCas = require('./latest');
var request = require('request');
require('https').globalAgent.options.ca = rootCas;
request.get('https://daplie.com/404.html', function (err, resp, body) {
if (err) {
throw err;
}
testInject();
});
}
function testInject() {
require('https').globalAgent.options.ca = null;
var rootCas = require('./latest').inject();
var request = require('request');
require('https').globalAgent.options.ca = rootCas;
request.get('https://daplie.com/404.html', function (err, resp, body) {
if (err) {
throw err;
}
testCreate();
});
}
function testCreate() {
require('https').globalAgent.options.ca = null;
var rootCas = require('./latest').create();
var request = require('request');
require('https').globalAgent.options.ca = rootCas;
request.get('https://daplie.com/404.html', function (err, resp, body) {
if (err) {
throw err;
}
console.log(body);
});
}
// TODO test with a company certificate