Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Self Signed #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<label for="node-config-input-tls"><i class="fa fa-shield"></i> TLS</label>
<input type="checkbox" id="node-config-input-tls" style="display:inline-block; width:auto; vertical-align:top;">
<label for="node-config-input-tls" style="width:auto !important;"> Encrypt connection to database</label>
</div>
<div class="form-row">
<label for="node-config-input-selfsigned"><i class="fa fa-shield"></i> Self Signed</label>
<input type="checkbox" id="node-config-input-selfsigned" style="display:inline-block; width:auto; vertical-align:top;">
<label for="node-config-input-selfsigned" style="width:auto !important;">Allow self signed certificates</label>
</div>
<div class="form-row">
<label for="node-config-input-token"><i class="fa fa-key"></i> Token</label>
Expand Down Expand Up @@ -48,7 +53,11 @@
tls: {
value: true,
required: true
}
},
selfsigned: {
value: false,
required: true
}
},
credentials: {
token: {
Expand Down
8 changes: 7 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = (RED) => {
'use strict';

const Influxdb = require('influxdb-v2');
const https = require('https');

function InfluxDbV2Node(config) {
RED.nodes.createNode(this, config);
Expand All @@ -11,7 +12,12 @@ module.exports = (RED) => {
host: config.host,
port: config.port,
protocol: config.tls ? 'https' : 'http',
token: this.credentials.token
token: this.credentials.token,
fetchOptions: {
agent: new https.Agent({
rejectUnauthorized: !config.selfsigned
})
}
});
};

Expand Down