From 56181f90071e862f8bd27d1b44f1f7613ac688a3 Mon Sep 17 00:00:00 2001 From: kuehnelbs Date: Mon, 30 Apr 2018 14:58:00 +0200 Subject: [PATCH 1/2] removed debug output --- nextcloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nextcloud.js b/nextcloud.js index d496cb4..273ef3b 100644 --- a/nextcloud.js +++ b/nextcloud.js @@ -172,7 +172,7 @@ module.exports = function(RED) { return } filename = filename.replace('//', '/') - node.warn(filename) + client.getFileContents(filename) .then(function (contents) { node.send({'payload': contents}) From 41b67ecc395180fa87dd17cc60962d265eb6dcf9 Mon Sep 17 00:00:00 2001 From: kuehnelbs Date: Tue, 1 May 2018 15:48:47 +0200 Subject: [PATCH 2/2] 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) --- CHANGELOG.md | 9 ++++++++- nextcloud.html | 9 ++++++++- nextcloud.js | 26 +++++++++++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55b5016..6a96ebb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # node-red-contrib-nextcloud changelog +## 0.1.1 +_2018-05-xx_ (work in progress) +* 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_ * addad missing option to set directory in incoming message for WebDAV list @@ -14,4 +20,5 @@ _2018-04-29_ * WebDAV Nodes * List directory entries * upload file to nextcloud server - * download file to nextcloud server \ No newline at end of file + * download file to nextcloud server + diff --git a/nextcloud.html b/nextcloud.html index 258847f..3e245bf 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 +
diff --git a/nextcloud.js b/nextcloud.js index 273ef3b..7b84acb 100644 --- a/nextcloud.js +++ b/nextcloud.js @@ -6,6 +6,7 @@ module.exports = function(RED) { function NextcloudConfigNode(n) { RED.nodes.createNode(this, n) this.address = n.address + this.insecure = n.insecure } RED.nodes.registerType('nextcloud-credentials', NextcloudConfigNode, { credentials: { @@ -140,9 +141,13 @@ module.exports = function(RED) { } else if (node.directory && node.directory.length) { directory = '/' + node.directory } + // check option for self signed certs + const option = {} + if (node.server.insecure) { + option.agent = new https.Agent({ rejectUnauthorized: false }) + } directory = directory.replace('//', '/') - - client.getDirectoryContents(directory) + client.getDirectoryContents(directory, option) .then(function (contents) { node.send({'payload': contents}) }, function (error) { @@ -172,8 +177,12 @@ module.exports = function(RED) { return } filename = filename.replace('//', '/') - - 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) { @@ -207,11 +216,14 @@ module.exports = function(RED) { directory += node.directory + '/' } directory = directory.replace('//', '/') - 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)})