diff --git a/CHANGELOG.md b/CHANGELOG.md index f56f72c..3292d6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ # node-red-contrib-nextcloud changelog -## 0.1,1 +## 0.1,2 _2018-11-11_ * merged pull request * fixed errors parsing caldav events * switched to ical-expander parser +## 0.1.1 +_2018-05-01 +* added checkbox to accept self signed server certificates to credentials +* added support for self signed certificates to WebDAV nodes (needs [webdav](https://github.com/perry-mitchell/webdav-client) package to be updated to 1.5.3 or newer) +* removed debug output in node WebDAV list ## 0.1.0 _2018-04-30_ diff --git a/nextcloud.html b/nextcloud.html index db60c34..905c8fe 100644 --- a/nextcloud.html +++ b/nextcloud.html @@ -3,7 +3,8 @@ category: 'config', defaults: { cname: {value: '', required: false}, - address: {value: 'https://your.server.com', required: true} + address: {value: 'https://your.server.com', required: true}, + insecure: {value: '', required: false} }, credentials: { user: {type:'text'}, @@ -27,6 +28,12 @@ +
+ + + Accept self signed certificates +
@@ -379,4 +386,4 @@
timeout number
Should be 0 in case of success
- \ No newline at end of file + diff --git a/nextcloud.js b/nextcloud.js index c738453..8e32616 100644 --- a/nextcloud.js +++ b/nextcloud.js @@ -4,10 +4,12 @@ module.exports = function (RED) { const fs = require('fs') const IcalExpander = require('ical-expander') const moment = require('moment') + const https = require('https') function NextcloudConfigNode (config) { RED.nodes.createNode(this, config) this.address = config.address + this.insecure = n.insecure } RED.nodes.registerType('nextcloud-credentials', NextcloudConfigNode, { credentials: { @@ -197,7 +199,12 @@ module.exports = function (RED) { } directory = directory.replace('//', '/') - client.getDirectoryContents(directory) + // check option for self signed certs + const option = {} + if (node.server.insecure) { + option.agent = new https.Agent({ rejectUnauthorized: false }) + } + client.getDirectoryContents(directory, option) .then(function (contents) { node.send({ 'payload': contents }) }, function (error) { @@ -226,8 +233,13 @@ module.exports = function (RED) { return } filename = filename.replace('//', '/') - node.warn(filename) - client.getFileContents(filename) + + // check option for self signed certs + const option = {} + if (node.server.insecure) { + option.agent = new https.Agent({ rejectUnauthorized: false }) + } + client.getFileContents(filename, option) .then(function (contents) { node.send({ 'payload': contents }) }, function (error) { @@ -264,7 +276,13 @@ module.exports = function (RED) { const webDavUri = node.server.address + '/remote.php/webdav/' const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass) - client.putFileContents(directory + name, file, { format: 'binary' }) + // check option for self signed certs + const option = {} + if (node.server.insecure) { + option.agent = new https.Agent({ rejectUnauthorized: false }) + } + + client.putFileContents(directory + name, file, { format: 'binary' }, option) .then(function (contents) { console.log(contents) node.send({ 'payload': JSON.parse(contents) }) diff --git a/package.json b/package.json index 6a03409..09a4ce0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-nextcloud", - "version": "0.1.1", + "version": "0.1.2", "description": "Collection of node-red nodes to download Calendars (CalDAV) and Contacts (CardDAV) and up- / download / list files (WebDAV) from / to nextcloud", "main": "nextcloud.js", "node-red": {