NEWS
Gotify "const axios" unable to verify the first certificate
-
Hallo,
ich habe den Selv Hostet Gotify benachrichtigungs Server der läuft erfolgreich auf HTTPS.Vorher hatte ich Gotify als HTTP am laufen und folgenden Code im Java Script dass hatte auch funktioniert.
const axios = require("axios"); const url = "http://192.168.178.xxx/message?token=ATvOgRNF8QqwGVN"; const bodyFormData = { title: "Hello from Javascript", message: "Test Push Service from Node.js", priority: 5, }; axios({ method: "post", headers: { "Content-Type": "application/json", }, url: url, data: bodyFormData, }) .then((response) => console.log(response.data)) .catch((err) => console.log(err.response ? error.response.data : err));
Seit der Umstellung auf HTTPS habe ich den Code so angepasst: (nur HTTP zu HTTPS geändert)
const axios = require("axios"); const url = "https://192.168.178.xxx/message?token=ATvOgRNF8QqwGVN"; const bodyFormData = { title: "Hello from Javascript", message: "Test Push Service from Node.js", priority: 5, }; axios({ method: "post", headers: { "Content-Type": "application/json", }, url: url, data: bodyFormData, }) .then((response) => console.log(response.data)) .catch((err) => console.log(err.response ? error.response.data : err));
Seitdem bekomme ich folgende fehlermeldung.
Ich habe zwar schon im Internet geschaut aber ich bin bischer leider erfolglos.{'message':'unable to verify the first certificate','name':'Error','stack':'Error: unable to verify the first certificate\n at Function.AxiosError.from (/opt/iobroker/node_modules/iobroker.javascript/node_modules/axios/dist/node/axios.cjs:837:14)\n at RedirectableRequest.handleRequestError (/opt/iobroker/node_modules/iobroker.javascript/node_modules/axios/dist/node/axios.cjs:3016:25)\n at RedirectableRequest.emit (node:events:514:28)\n at ClientRequest.eventHandlers.<computed> (/opt/iobroker/node_modules/follow-redirects/index.js:14:24)\n at ClientRequest.emit (node:events:514:28)\n at TLSSocket.socketErrorListener (node:_http_client:501:9)\n at TLSSocket.emit (node:events:514:28)\n at emitErrorNT (node:internal/streams/destroy:151:8)\n at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)\n','config':{'transitional':{'silentJSONParsing':true,'forcedJSONParsing':true,'clarifyTimeoutError':false},'adapter':'http','transformRequest':[null],'transformResponse':[null],'timeout':0,'xsrfCookieName':'XSRF-TOKEN','xsrfHeaderName':'X-XSRF-TOKEN','maxContentLength':-1,'maxBodyLength':-1,'env':{},'headers':{'Accept':'application/json, text/plain, */*','Content-Type':'application/json','User-Agent':'axios/1.5.0','Content-Length':'89','Accept-Encoding':'gzip, compress, deflate, br'},'method':'post','url':'https://192.168.178.xxx/message?token=ATvOgRNF8QqwGVN','data':'{\'title\':\'Hello from Javascript\',\'message\':\'Test Push Service from Node.js\',\'priority\':5}'},'code':'UNABLE_TO_VERIFY_LEAF_SIGNATURE','status':null}
Hat einer eine idee wie ich das SSL im Code ausschalten kann oder noch besser wie ich dass mit einem Zertifikat hinbekomme also Zertifikat habe ich ja ich weiß nur nicht wie ich dass coden soll.
-
@benjamincz sagte in Gotify "const axios" unable to verify the first certificate:
Hallo,
ich habe den Selv Hostet Gotify benachrichtigungs Server der läuft erfolgreich auf HTTPS.Vorher hatte ich Gotify als HTTP am laufen und folgenden Code im Java Script dass hatte auch funktioniert.
const axios = require("axios"); const url = "http://192.168.178.xxx/message?token=ATvOgRNF8QqwGVN"; const bodyFormData = { title: "Hello from Javascript", message: "Test Push Service from Node.js", priority: 5, }; axios({ method: "post", headers: { "Content-Type": "application/json", }, url: url, data: bodyFormData, }) .then((response) => console.log(response.data)) .catch((err) => console.log(err.response ? error.response.data : err));
Seit der Umstellung auf HTTPS habe ich den Code so angepasst: (nur HTTP zu HTTPS geändert)
const axios = require("axios"); const url = "https://192.168.178.xxx/message?token=ATvOgRNF8QqwGVN"; const bodyFormData = { title: "Hello from Javascript", message: "Test Push Service from Node.js", priority: 5, }; axios({ method: "post", headers: { "Content-Type": "application/json", }, url: url, data: bodyFormData, }) .then((response) => console.log(response.data)) .catch((err) => console.log(err.response ? error.response.data : err));
Seitdem bekomme ich folgende fehlermeldung.
Ich habe zwar schon im Internet geschaut aber ich bin bischer leider erfolglos.{'message':'unable to verify the first certificate','name':'Error','stack':'Error: unable to verify the first certificate\n at Function.AxiosError.from (/opt/iobroker/node_modules/iobroker.javascript/node_modules/axios/dist/node/axios.cjs:837:14)\n at RedirectableRequest.handleRequestError (/opt/iobroker/node_modules/iobroker.javascript/node_modules/axios/dist/node/axios.cjs:3016:25)\n at RedirectableRequest.emit (node:events:514:28)\n at ClientRequest.eventHandlers.<computed> (/opt/iobroker/node_modules/follow-redirects/index.js:14:24)\n at ClientRequest.emit (node:events:514:28)\n at TLSSocket.socketErrorListener (node:_http_client:501:9)\n at TLSSocket.emit (node:events:514:28)\n at emitErrorNT (node:internal/streams/destroy:151:8)\n at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)\n','config':{'transitional':{'silentJSONParsing':true,'forcedJSONParsing':true,'clarifyTimeoutError':false},'adapter':'http','transformRequest':[null],'transformResponse':[null],'timeout':0,'xsrfCookieName':'XSRF-TOKEN','xsrfHeaderName':'X-XSRF-TOKEN','maxContentLength':-1,'maxBodyLength':-1,'env':{},'headers':{'Accept':'application/json, text/plain, */*','Content-Type':'application/json','User-Agent':'axios/1.5.0','Content-Length':'89','Accept-Encoding':'gzip, compress, deflate, br'},'method':'post','url':'https://192.168.178.xxx/message?token=ATvOgRNF8QqwGVN','data':'{\'title\':\'Hello from Javascript\',\'message\':\'Test Push Service from Node.js\',\'priority\':5}'},'code':'UNABLE_TO_VERIFY_LEAF_SIGNATURE','status':null}
Hat einer eine idee wie ich das SSL im Code ausschalten kann oder noch besser wie ich dass mit einem Zertifikat hinbekomme also Zertifikat habe ich ja ich weiß nur nicht wie ich dass coden soll.
Bin Hier fündig geworden aber leider weiß ich nicht wie in das coden soll:
Link Text -
import https from 'https' // oder const https = require('https') import axios from 'axios' const httpsAgent = new https.Agent({ rejectUnauthorized: false, }) axios.defaults.httpsAgent = httpsAgent //hier rest vom Script
So in der Art.
https muß wohl im Javascript-Adapter in die npm module, kannst aber mal ohne versuchen, wenn dann ein Fehler kommt mit Modul nicht gefunden, muß er rein.