diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index 35829cb..0640549 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -15,9 +15,10 @@ function safeParseJson(json) { } } -function ProjectionsClient(log, operationTimeout) { +function ProjectionsClient(log, operationTimeout, rejectUnauthorized) { this._log = log; this._operationTimeout = operationTimeout; + this._rejectUnauthorized = typeof rejectUnauthorized === 'undefined' ? true : !!rejectUnauthorized; } ProjectionsClient.prototype.enable = function(httpEndPoint, name, userCredentials) { @@ -118,6 +119,9 @@ ProjectionsClient.prototype.request = function(method, _url, data, userCredentia if (userCredentials) { options.auth = [userCredentials.username, userCredentials.password].join(':'); } + if (!this._rejectUnauthorized) { + options.rejectUnauthorized = false; + } var self = this; return new Promise(function (resolve, reject) { const timeout = setTimeout(function () { diff --git a/src/projections/projectionsManager.js b/src/projections/projectionsManager.js index da04ef2..1992213 100644 --- a/src/projections/projectionsManager.js +++ b/src/projections/projectionsManager.js @@ -6,12 +6,13 @@ const ProjectionsClient = require('./projectionsClient'); * @param {Logger} log Instance of Logger to use for logging. * @param {string} httpEndPoint HTTP endpoint of an Event Store server. * @param {number} operationTimeout Operation timeout in milliseconds. + * @param {boolean} [rejectUnauthorized] Reject authorized SSL certs (if using SSL) - set to false is using self-signed certs * @constructor */ -function ProjectionsManager(log, httpEndPoint, operationTimeout) { +function ProjectionsManager(log, httpEndPoint, operationTimeout, rejectUnauthorized) { ensure.notNull(log, "log"); ensure.notNull(httpEndPoint, "httpEndPoint"); - this._client = new ProjectionsClient(log, operationTimeout); + this._client = new ProjectionsClient(log, operationTimeout, rejectUnauthorized); this._httpEndPoint = httpEndPoint; } @@ -211,4 +212,4 @@ ProjectionsManager.prototype.delete = function(name, deleteEmittedStreams, delet return this._client.delete(this._httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials); }; -module.exports = ProjectionsManager; \ No newline at end of file +module.exports = ProjectionsManager; diff --git a/test/common/base_test.js b/test/common/base_test.js index 88a49a2..60e14b8 100644 --- a/test/common/base_test.js +++ b/test/common/base_test.js @@ -12,6 +12,8 @@ protobufJS.configure(); var settings = { log: new NoopLogger(), + useSslConnection: true, + validateServer: false }; if (process.env.TESTS_VERBOSE_LOGGING === '1') { settings.verboseLogging = true; diff --git a/test/persistentSubscription_test.js b/test/persistentSubscription_test.js index 4fd40f4..9f1d717 100644 --- a/test/persistentSubscription_test.js +++ b/test/persistentSubscription_test.js @@ -41,7 +41,7 @@ module.exports = { done(); } var self = this; - this.conn.connectToPersistentSubscription(testStreamName, 'consumer-1', eventAppeared, subscriptionDropped) + this.conn.connectToPersistentSubscription(testStreamName, 'consumer-1', eventAppeared, subscriptionDropped, adminCredentials) .then(function(subscription) { test.ok(subscription, "Subscription is null."); return self.conn.appendToStream(testStreamName, client.expectedVersion.any, [createRandomEvent(), createRandomEvent()]); diff --git a/test/projections_test.js b/test/projections_test.js index 5ff603d..58a6e99 100644 --- a/test/projections_test.js +++ b/test/projections_test.js @@ -2,7 +2,7 @@ const client = require('../lib/dist'); const userCredentials = new client.UserCredentials('admin', 'changeit'); const log = new client.NoopLogger(); -const httpEndpoint = `http://${process.env.EVENTSTORE_HOST || "localhost"}:2113`; +const httpEndpoint = `https://${process.env.EVENTSTORE_HOST || "localhost"}:2113`; const operationTimeout = 5000; const simpleProjection = "\ @@ -21,7 +21,7 @@ fromStream('$stats-127.0.0.1:2113')\ module.exports = { setUp: function(cb) { - this.projectionsManager = new client.ProjectionsManager(log, httpEndpoint, operationTimeout); + this.projectionsManager = new client.ProjectionsManager(log, httpEndpoint, operationTimeout, false); cb(); }, 'Create One Time Projection Happy Path': function(test) {