From dc2212a57fe63c645849b8a6ff81ebcc8da3b33a Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 5 Jun 2017 10:22:15 -0400 Subject: [PATCH] fix(GUI): ignore UNABLE_TO_VERIFY_LEAF_SIGNATURE HTTP issues (#1473) This error may get thrown when fetching the list of S3 packages when the user is behind a proxy tht causes the SSL certificate to incorrectly not be trusted. See: https://github.com/atom/apm/issues/103 See: https://github.com/resin-io/etcher/issues/1465 Change-Type: patch Changelog-Entry: Fix `UNABLE_TO_VERIFY_LEAF_SIGNATURE` error at startup. Signed-off-by: Juan Cruz Viotti --- lib/shared/s3-packages.js | 5 +++++ tests/shared/s3-packages.spec.js | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/shared/s3-packages.js b/lib/shared/s3-packages.js index 6d770e13..8a38a8a6 100644 --- a/lib/shared/s3-packages.js +++ b/lib/shared/s3-packages.js @@ -156,6 +156,11 @@ exports.getRemoteVersions = _.memoize((bucketUrl) => { code: 'EACCES' }, { code: 'ETIMEDOUT' + }, { + + // May happen when behind a proxy + code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' + }, () => { return []; }); diff --git a/tests/shared/s3-packages.spec.js b/tests/shared/s3-packages.spec.js index 0bbe6f6a..60917bfa 100644 --- a/tests/shared/s3-packages.spec.js +++ b/tests/shared/s3-packages.spec.js @@ -712,6 +712,29 @@ describe('Shared: s3Packages', function() { }); + describe('given UNABLE_TO_VERIFY_LEAF_SIGNATURE', function() { + + beforeEach(function() { + const error = new Error('UNABLE_TO_VERIFY_LEAF_SIGNATURE'); + error.code = 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'; + + this.requestGetAsyncStub = m.sinon.stub(request, 'getAsync'); + this.requestGetAsyncStub.returns(Bluebird.reject(error)); + }); + + afterEach(function() { + this.requestGetAsyncStub.restore(); + }); + + it('should resolve an empty array', function(done) { + s3Packages.getRemoteVersions(s3Packages.BUCKET_URL.PRODUCTION).then((versions) => { + m.chai.expect(versions).to.deep.equal([]); + done(); + }).catch(done); + }); + + }); + }); describe('.getLatestVersion()', function() {