Skip to content

Commit

Permalink
removed workaround for intermediate certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
Black-Thunder committed Jul 30, 2023
1 parent 5c03b49 commit fe5ad62
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 173 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Documentation:
Placeholder for the next version (at the beginning of the line):
### __WORK IN PROGRESS__
-->
### __WORK IN PROGRESS__
* (Black-Thunder) Memory leak was fixed

### 1.3.4 (2023-05-11)
* (Black-Thunder) Certificate issues were fixed (e.g. "Error: unable to verify the first certificate")

Expand Down
11 changes: 6 additions & 5 deletions lib/melcloudAtaDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const commonDefines = require("./commonDefines");
const HttpStatus = require("http-status-codes");
const Axios = require("axios").default;

let gthat = null; // pointer to "this" from main.js/MelCloud instance

Expand Down Expand Up @@ -877,7 +878,7 @@ class MelcloudAtaDevice {

const url = `https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/Get?id=${gthis.id}&buildingID=${gthis.buildingId}`;

gthat.mainAxiosInstance.get(url, {
Axios.get(url, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey
}
Expand Down Expand Up @@ -1016,7 +1017,7 @@ class MelcloudAtaDevice {
const body = JSON.stringify(modifiedAirInfo);
gthat.log.silly(`Request body: ${body}`);

gthat.mainAxiosInstance.post(url, body, {
Axios.post(url, body, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey,
"content-type": "application/json"
Expand Down Expand Up @@ -1178,7 +1179,7 @@ class MelcloudAtaDevice {

if (body == "{}") return; // creating body failed or was provided dates were invalid

gthat.mainAxiosInstance.post(url, body, {
Axios.post(url, body, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey,
"content-type": "application/json"
Expand Down Expand Up @@ -1297,7 +1298,7 @@ class MelcloudAtaDevice {
// Step 1: Get current timer infos
const getTimerUrl = `https://app.melcloud.com/Mitsubishi.Wifi.Client/Timer/Get2?deviceId=${gthis.id}`;

gthat.mainAxiosInstance.get(getTimerUrl, {
Axios.get(getTimerUrl, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey
}
Expand Down Expand Up @@ -1345,7 +1346,7 @@ class MelcloudAtaDevice {
const body = JSON.stringify(toggleRequest);
gthat.log.silly(`Request body: ${body}`);

gthat.mainAxiosInstance.post(setTimerUrl, body, {
Axios.post(setTimerUrl, body, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey,
"content-type": "application/json"
Expand Down
11 changes: 6 additions & 5 deletions lib/melcloudAtwDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const commonDefines = require("./commonDefines");
const HttpStatus = require("http-status-codes");
const Axios = require("axios").default;

let gthat = null; // pointer to "this" from main.js/MelCloud instance

Expand Down Expand Up @@ -1102,7 +1103,7 @@ class MelcloudAtwDevice {

const url = `https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/Get?id=${gthis.id}&buildingID=${gthis.buildingId}`;

gthat.mainAxiosInstance.get(url, {
Axios.get(url, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey
}
Expand Down Expand Up @@ -1289,7 +1290,7 @@ class MelcloudAtwDevice {
const body = JSON.stringify(modifiedAirInfo);
gthat.log.silly(`Request body: ${body}`);

gthat.mainAxiosInstance.post(url, body, {
Axios.post(url, body, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey,
"content-type": "application/json"
Expand Down Expand Up @@ -1399,7 +1400,7 @@ class MelcloudAtwDevice {

if (body == "{}") return; // creating body failed or was provided dates were invalid

gthat.mainAxiosInstance.post(url, body, {
Axios.post(url, body, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey,
"content-type": "application/json"
Expand Down Expand Up @@ -1521,7 +1522,7 @@ class MelcloudAtwDevice {
// Step 1: Get current timer infos
const getTimerUrl = `https://app.melcloud.com/Mitsubishi.Wifi.Client/Timer/Get2?deviceId=${gthis.id}`;

gthat.mainAxiosInstance.get(getTimerUrl, {
Axios.get(getTimerUrl, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey
}
Expand Down Expand Up @@ -1569,7 +1570,7 @@ class MelcloudAtwDevice {
const body = JSON.stringify(toggleRequest);
gthat.log.silly(`Request body: ${body}`);

gthat.mainAxiosInstance.post(setTimerUrl, body, {
Axios.post(setTimerUrl, body, {
headers: {
"X-MitsContextKey": gthis.platform.contextKey,
"content-type": "application/json"
Expand Down
5 changes: 3 additions & 2 deletions lib/melcloudPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const MelCloudAtaDevice = require("./melcloudAtaDevice");
const MelCloudAtwDevice = require("./melcloudAtwDevice");
const commonDefines = require("./commonDefines");
const HttpStatus = require("http-status-codes");
const Axios = require("axios").default;

let gthat = null; // pointer to "this" from main.js/MelCloud instance
let gthis = null; // pointer to "this" from MelcloudPlatform
Expand Down Expand Up @@ -39,7 +40,7 @@ class MelcloudPlatform {
form.append("Password", gthis.password);
form.append("Persist", "true");

gthat.mainAxiosInstance.post(loginUrl, form, { headers: form.getHeaders() })
Axios.post(loginUrl, form, { headers: form.getHeaders() })
.then(function handleLoginResponse(response) {
if (!response) {
gthat.log.error(`There was a problem receiving the response from: ${loginUrl}`);
Expand Down Expand Up @@ -100,7 +101,7 @@ class MelcloudPlatform {

const url = "https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices";

gthat.mainAxiosInstance.get(url, {
Axios.get(url, {
headers: {
"X-MitsContextKey": gthis.contextKey
}
Expand Down
120 changes: 0 additions & 120 deletions lib/melcloud_intermediate.pem

This file was deleted.

10 changes: 0 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ const utils = require("@iobroker/adapter-core");
// Needed modules
const cloudPlatform = require("./lib/melcloudPlatform");
const commonDefines = require("./lib/commonDefines");
const Axios = require("axios").default;
const Https = require("https");
const RootCas = require("ssl-root-cas").create();
const Path = require("path");

let gthis = null; // global to 'this' of Melcloud main instance
let CloudPlatform = null;
Expand All @@ -35,12 +31,6 @@ class Melcloud extends utils.Adapter {
gthis = this;
this.deviceObjects = []; // array of all device objects
this.currentKnownDeviceIDs = []; // array of all current known device IDs

// MELCloud intermediate certificate, needed as otherwise requests will fail with "Unable to verify the first certificate"
RootCas.addFile(Path.resolve(__dirname, "lib/melcloud_intermediate.pem"));
this.mainAxiosInstance = Axios.create({
httpsAgent: new Https.Agent({ ca: RootCas })
});
}

async checkSettings() {
Expand Down
29 changes: 1 addition & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"@iobroker/adapter-core": "^2.6.8",
"axios": "^1.4.0",
"form-data": "^4.0.0",
"http-status-codes": "^2.2.0",
"ssl-root-cas": "^1.3.1"
"http-status-codes": "^2.2.0"
},
"devDependencies": {
"@alcalzone/release-script": "^3.6.0",
Expand Down Expand Up @@ -68,4 +67,4 @@
"url": "https://github.com/Black-Thunder/ioBroker.melcloud/issues"
},
"readmeFilename": "README.md"
}
}

0 comments on commit fe5ad62

Please sign in to comment.