From 04491ac5aca2176adcbfc773906050e78cc8f8ee Mon Sep 17 00:00:00 2001 From: Krouty Date: Sat, 13 Feb 2021 17:13:00 +0100 Subject: [PATCH 1/6] This is supposed to make self signed certs work with the calendar module Many people use Own-/Nextcloud together witht he https protocol. This is supposed to make self-signed certificates work with the calendar module and fix the issue #466. --- modules/default/calendar/calendarfetcher.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 6c268c46..d4aa7b02 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -50,6 +50,13 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn }, gzip: true }; + + if (selfSignedCert) { + var agentOptions = { + rejectUnauthorized: false + }; + opts.agentOptions = agentOptions; + } if (auth) { if (auth.method === "bearer") { From 1aacc37c831aa16b2f61c39fd0452b73f00bf82b Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 10:29:40 +0100 Subject: [PATCH 2/6] Added selfSignedCert as a parameter Added selfSignedCert as a parameter, so that it can be enabled only when it is required. --- modules/default/calendar/calendarfetcher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index d4aa7b02..91d1689b 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -25,9 +25,10 @@ const moment = require("moment"); * @param {number} maximumNumberOfDays The maximum number of days an event should be in the future. * @param {object} auth The object containing options for authentication against the calendar. * @param {boolean} includePastEvents If true events from the past maximumNumberOfDays will be fetched too + * @param {boolean} selfSignedCert If true, the server certificate is not verified against the list of supplied CAs. * @class */ -const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents) { +const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents, selfSignedCert) { const self = this; let reloadTimer = null; From c6aff8b7dcf0c42baae63528b7579dac2ca80aef Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 11:29:19 +0100 Subject: [PATCH 3/6] Added suppoert for self-signed certificates Added support for self-signed certificates --- modules/default/calendar/calendar.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index a4346c64..2cce00c7 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -58,7 +58,8 @@ Module.register("calendar", { excludedEvents: [], sliceMultiDayEvents: false, broadcastPastEvents: false, - nextDaysRelative: false + nextDaysRelative: false, + selfSignedCert: false }, requiresVersion: "2.1.0", @@ -101,7 +102,8 @@ Module.register("calendar", { var calendarConfig = { maximumEntries: calendar.maximumEntries, maximumNumberOfDays: calendar.maximumNumberOfDays, - broadcastPastEvents: calendar.broadcastPastEvents + broadcastPastEvents: calendar.broadcastPastEvents, + selfSignedCert: calendar.selfSignedCert }; if (calendar.symbolClass === "undefined" || calendar.symbolClass === null) { calendarConfig.symbolClass = ""; @@ -606,7 +608,8 @@ Module.register("calendar", { titleClass: calendarConfig.titleClass, timeClass: calendarConfig.timeClass, auth: auth, - broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents + broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents, + selfSignedCert: calendarConfig.selfSignedCert || this.config.selfSignedCert }); }, From beb5faef8b80048ed4e3410aba0ed099007ba250 Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 11:32:03 +0100 Subject: [PATCH 4/6] Added support for self-signed certificates Added support for self-signed certificates --- modules/default/calendar/node_helper.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 06fa28ec..3b6e4a55 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -19,7 +19,7 @@ module.exports = NodeHelper.create({ // Override socketNotificationReceived method. socketNotificationReceived: function (notification, payload) { if (notification === "ADD_CALENDAR") { - this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.id); + this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.selfSignedCert, payload.id); } }, @@ -34,9 +34,10 @@ module.exports = NodeHelper.create({ * @param {number} maximumNumberOfDays The maximum number of days an event should be in the future. * @param {object} auth The object containing options for authentication against the calendar. * @param {boolean} broadcastPastEvents If true events from the past maximumNumberOfDays will be included in event broadcasts + * @param {boolean} selfSignedCert If true, the server certificate is not verified against the list of supplied CAs. * @param {string} identifier ID of the module */ - createFetcher: function (url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, identifier) { + createFetcher: function (url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, selfSignedCert, identifier) { var self = this; if (!validUrl.isUri(url)) { @@ -47,7 +48,7 @@ module.exports = NodeHelper.create({ var fetcher; if (typeof self.fetchers[identifier + url] === "undefined") { Log.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval); - fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents); + fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, selfSignedCert); fetcher.onReceive(function (fetcher) { self.sendSocketNotification("CALENDAR_EVENTS", { From 1db0dbf52bae6cff399e3d3380bdfd5c0c6d189c Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 11:45:15 +0100 Subject: [PATCH 5/6] Added support for self-signed certificates Added support for self-signed certificates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8e29a0..b08ff58e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ _This release is scheduled to be released on 2021-04-01._ - Portuguese translations for "MODULE_CONFIG_CHANGED" and PRECIP. - Respect parameter ColoredSymbolOnly also for custom events - Added a new parameter to hide time portion on relative times +- Added support for self-signed certificates for the default calendar module (#466) ### Updated From 5b270b84b4dc1a65313923b70595315532071997 Mon Sep 17 00:00:00 2001 From: config Date: Sun, 21 Feb 2021 19:56:02 +0100 Subject: [PATCH 6/6] linted calendarfetcher.js --- modules/default/calendar/calendarfetcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 91d1689b..92c6d38f 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -51,12 +51,12 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn }, gzip: true }; - + if (selfSignedCert) { var agentOptions = { rejectUnauthorized: false }; - opts.agentOptions = agentOptions; + opts.agentOptions = agentOptions; } if (auth) {