Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Gotify "const axios" unable to verify the first certificate

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Gotify "const axios" unable to verify the first certificate

    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      BenjaminCz last edited by BenjaminCz

      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.

      B 1 Reply Last reply Reply Quote 0
      • B
        BenjaminCz @BenjaminCz last edited by BenjaminCz

        @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

        T 1 Reply Last reply Reply Quote 0
        • T
          ticaki Developer @BenjaminCz last edited by ticaki

          @benjamincz

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          990
          Online

          31.7k
          Users

          79.6k
          Topics

          1.3m
          Posts

          2
          3
          541
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo