unable to verify the first certificate in nodejs with loopbackjs












1















In the following code, I was trying to check that UUID is already generated or not. I tried to use https.request instead of https.get to check may be the error is solved but the result was the same. Also, I add the key and crt in https.request which is used in loopback SSL config to pass the problem but no difference has appeared.



const options = {
hostname: 'app.mydomain.com', //same as localhost:3000
port: 443,
path: '/api/uuids?filter[where][uuid]=' + UUID,
method: 'GET',

key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
};
console.log(options);
const req = https.request(options, (res) => {

res.on('data', (d) => {
d = JSON.parse(d)
console.log(d);
if (d.length == 1 && d[0].uuid == UID) {

return 200;
}
else {
return 500;
}
});
});

req.on('error', (e) => {
console.error(e);
});


console error:



(node:4452) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
{ Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
at TLSSocket.emit (events.js:182:13)
at TLSSocket._finishInit (_tls_wrap.js:631:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }


I tried to also use:



    const https = require('https').globalAgent.options.ca = require('ssl-root-cas/latest').create();

In the declaration of `https` but the following error appears:

(node:4500) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
Unhandled error for request POST /registrations: TypeError: https.request is not a function
at checkUUID (C:appsappcommonmodelsregistration.js:60:20)
at C:appsappcommonmodelsregistration.js:16:17
at notifySingleObserver (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:160:22)
at C:appsappnode_modulesasyncdistasync.js:3110:16
at replenish (C:appsappnode_modulesasyncdistasync.js:1011:17)
at C:appsappnode_modulesasyncdistasync.js:1016:9
at eachLimit$1 (C:appsappnode_modulesasyncdistasync.js:3196:24)
at Object.<anonymous> (C:appsappnode_modulesasyncdistasync.js:1046:16)
at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:157:11)
at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)


additional information




  • I am using my personal server as vps/dedicated server

  • I am using Nginx with proxy rever for app.mydomain.com mydomain.com +
    wwww.mydomain.com + app.mydomain.com all of them are accessible by
    only ssl andport 443.

  • I used zerossl to get certificates for my domain and subs.

  • I used the same key and cert that site generated for
    loopbackjs ssl config










share|improve this question





























    1















    In the following code, I was trying to check that UUID is already generated or not. I tried to use https.request instead of https.get to check may be the error is solved but the result was the same. Also, I add the key and crt in https.request which is used in loopback SSL config to pass the problem but no difference has appeared.



    const options = {
    hostname: 'app.mydomain.com', //same as localhost:3000
    port: 443,
    path: '/api/uuids?filter[where][uuid]=' + UUID,
    method: 'GET',

    key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
    cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
    };
    console.log(options);
    const req = https.request(options, (res) => {

    res.on('data', (d) => {
    d = JSON.parse(d)
    console.log(d);
    if (d.length == 1 && d[0].uuid == UID) {

    return 200;
    }
    else {
    return 500;
    }
    });
    });

    req.on('error', (e) => {
    console.error(e);
    });


    console error:



    (node:4452) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
    { Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:631:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }


    I tried to also use:



        const https = require('https').globalAgent.options.ca = require('ssl-root-cas/latest').create();

    In the declaration of `https` but the following error appears:

    (node:4500) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
    Unhandled error for request POST /registrations: TypeError: https.request is not a function
    at checkUUID (C:appsappcommonmodelsregistration.js:60:20)
    at C:appsappcommonmodelsregistration.js:16:17
    at notifySingleObserver (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:160:22)
    at C:appsappnode_modulesasyncdistasync.js:3110:16
    at replenish (C:appsappnode_modulesasyncdistasync.js:1011:17)
    at C:appsappnode_modulesasyncdistasync.js:1016:9
    at eachLimit$1 (C:appsappnode_modulesasyncdistasync.js:3196:24)
    at Object.<anonymous> (C:appsappnode_modulesasyncdistasync.js:1046:16)
    at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:157:11)
    at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
    at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
    at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
    at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
    at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
    at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
    at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)


    additional information




    • I am using my personal server as vps/dedicated server

    • I am using Nginx with proxy rever for app.mydomain.com mydomain.com +
      wwww.mydomain.com + app.mydomain.com all of them are accessible by
      only ssl andport 443.

    • I used zerossl to get certificates for my domain and subs.

    • I used the same key and cert that site generated for
      loopbackjs ssl config










    share|improve this question



























      1












      1








      1








      In the following code, I was trying to check that UUID is already generated or not. I tried to use https.request instead of https.get to check may be the error is solved but the result was the same. Also, I add the key and crt in https.request which is used in loopback SSL config to pass the problem but no difference has appeared.



      const options = {
      hostname: 'app.mydomain.com', //same as localhost:3000
      port: 443,
      path: '/api/uuids?filter[where][uuid]=' + UUID,
      method: 'GET',

      key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
      cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
      };
      console.log(options);
      const req = https.request(options, (res) => {

      res.on('data', (d) => {
      d = JSON.parse(d)
      console.log(d);
      if (d.length == 1 && d[0].uuid == UID) {

      return 200;
      }
      else {
      return 500;
      }
      });
      });

      req.on('error', (e) => {
      console.error(e);
      });


      console error:



      (node:4452) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
      { Error: unable to verify the first certificate
      at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
      at TLSSocket.emit (events.js:182:13)
      at TLSSocket._finishInit (_tls_wrap.js:631:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }


      I tried to also use:



          const https = require('https').globalAgent.options.ca = require('ssl-root-cas/latest').create();

      In the declaration of `https` but the following error appears:

      (node:4500) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
      Unhandled error for request POST /registrations: TypeError: https.request is not a function
      at checkUUID (C:appsappcommonmodelsregistration.js:60:20)
      at C:appsappcommonmodelsregistration.js:16:17
      at notifySingleObserver (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:160:22)
      at C:appsappnode_modulesasyncdistasync.js:3110:16
      at replenish (C:appsappnode_modulesasyncdistasync.js:1011:17)
      at C:appsappnode_modulesasyncdistasync.js:1016:9
      at eachLimit$1 (C:appsappnode_modulesasyncdistasync.js:3196:24)
      at Object.<anonymous> (C:appsappnode_modulesasyncdistasync.js:1046:16)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:157:11)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
      at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
      at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
      at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
      at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)


      additional information




      • I am using my personal server as vps/dedicated server

      • I am using Nginx with proxy rever for app.mydomain.com mydomain.com +
        wwww.mydomain.com + app.mydomain.com all of them are accessible by
        only ssl andport 443.

      • I used zerossl to get certificates for my domain and subs.

      • I used the same key and cert that site generated for
        loopbackjs ssl config










      share|improve this question
















      In the following code, I was trying to check that UUID is already generated or not. I tried to use https.request instead of https.get to check may be the error is solved but the result was the same. Also, I add the key and crt in https.request which is used in loopback SSL config to pass the problem but no difference has appeared.



      const options = {
      hostname: 'app.mydomain.com', //same as localhost:3000
      port: 443,
      path: '/api/uuids?filter[where][uuid]=' + UUID,
      method: 'GET',

      key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
      cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
      };
      console.log(options);
      const req = https.request(options, (res) => {

      res.on('data', (d) => {
      d = JSON.parse(d)
      console.log(d);
      if (d.length == 1 && d[0].uuid == UID) {

      return 200;
      }
      else {
      return 500;
      }
      });
      });

      req.on('error', (e) => {
      console.error(e);
      });


      console error:



      (node:4452) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
      { Error: unable to verify the first certificate
      at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
      at TLSSocket.emit (events.js:182:13)
      at TLSSocket._finishInit (_tls_wrap.js:631:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }


      I tried to also use:



          const https = require('https').globalAgent.options.ca = require('ssl-root-cas/latest').create();

      In the declaration of `https` but the following error appears:

      (node:4500) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
      Unhandled error for request POST /registrations: TypeError: https.request is not a function
      at checkUUID (C:appsappcommonmodelsregistration.js:60:20)
      at C:appsappcommonmodelsregistration.js:16:17
      at notifySingleObserver (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:160:22)
      at C:appsappnode_modulesasyncdistasync.js:3110:16
      at replenish (C:appsappnode_modulesasyncdistasync.js:1011:17)
      at C:appsappnode_modulesasyncdistasync.js:1016:9
      at eachLimit$1 (C:appsappnode_modulesasyncdistasync.js:3196:24)
      at Object.<anonymous> (C:appsappnode_modulesasyncdistasync.js:1046:16)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:157:11)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
      at doNotify (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:155:49)
      at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:178:5)
      at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)
      at Function.ObserverMixin._notifyBaseObservers (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:176:15)
      at Function.ObserverMixin.notifyObserversOf (C:appsappnode_modulesloopback-datasource-jugglerlibobserver.js:153:8)


      additional information




      • I am using my personal server as vps/dedicated server

      • I am using Nginx with proxy rever for app.mydomain.com mydomain.com +
        wwww.mydomain.com + app.mydomain.com all of them are accessible by
        only ssl andport 443.

      • I used zerossl to get certificates for my domain and subs.

      • I used the same key and cert that site generated for
        loopbackjs ssl config







      javascript node.js ssl nginx loopbackjs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 8:27







      RSA

















      asked Dec 31 '18 at 7:09









      RSARSA

      6631925




      6631925
























          1 Answer
          1






          active

          oldest

          votes


















          1














          after 2 days I find how to solve it, I used these code:



          var rootCas = require('ssl-root-cas/latest').create();
          rootCas.addFile(__dirname + './../../server/ssl/domain.crt');
          const https = require('https');//.globalAgent.options.ca = require('ssl-root-cas/latest').create();
          var request = require('request');


          and



           const options = {
          hostname: 'app.mydomain.com',
          port: 443,
          path: '/api/uuids?filter[where][uuid]=' + UID,
          method: 'GET',
          key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
          cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
          };
          const req = https.get(options, (res) => {
          res.on('data', (d) => {
          d = JSON.parse(d)
          if (d.length == 1 && d[0].uuid == UID) {

          return 200;
          }
          else {
          return 500;
          }
          });
          });

          req.on('error', (e) => {
          console.error(e);
          });





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984616%2funable-to-verify-the-first-certificate-in-nodejs-with-loopbackjs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            after 2 days I find how to solve it, I used these code:



            var rootCas = require('ssl-root-cas/latest').create();
            rootCas.addFile(__dirname + './../../server/ssl/domain.crt');
            const https = require('https');//.globalAgent.options.ca = require('ssl-root-cas/latest').create();
            var request = require('request');


            and



             const options = {
            hostname: 'app.mydomain.com',
            port: 443,
            path: '/api/uuids?filter[where][uuid]=' + UID,
            method: 'GET',
            key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
            cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
            };
            const req = https.get(options, (res) => {
            res.on('data', (d) => {
            d = JSON.parse(d)
            if (d.length == 1 && d[0].uuid == UID) {

            return 200;
            }
            else {
            return 500;
            }
            });
            });

            req.on('error', (e) => {
            console.error(e);
            });





            share|improve this answer




























              1














              after 2 days I find how to solve it, I used these code:



              var rootCas = require('ssl-root-cas/latest').create();
              rootCas.addFile(__dirname + './../../server/ssl/domain.crt');
              const https = require('https');//.globalAgent.options.ca = require('ssl-root-cas/latest').create();
              var request = require('request');


              and



               const options = {
              hostname: 'app.mydomain.com',
              port: 443,
              path: '/api/uuids?filter[where][uuid]=' + UID,
              method: 'GET',
              key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
              cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
              };
              const req = https.get(options, (res) => {
              res.on('data', (d) => {
              d = JSON.parse(d)
              if (d.length == 1 && d[0].uuid == UID) {

              return 200;
              }
              else {
              return 500;
              }
              });
              });

              req.on('error', (e) => {
              console.error(e);
              });





              share|improve this answer


























                1












                1








                1







                after 2 days I find how to solve it, I used these code:



                var rootCas = require('ssl-root-cas/latest').create();
                rootCas.addFile(__dirname + './../../server/ssl/domain.crt');
                const https = require('https');//.globalAgent.options.ca = require('ssl-root-cas/latest').create();
                var request = require('request');


                and



                 const options = {
                hostname: 'app.mydomain.com',
                port: 443,
                path: '/api/uuids?filter[where][uuid]=' + UID,
                method: 'GET',
                key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
                cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
                };
                const req = https.get(options, (res) => {
                res.on('data', (d) => {
                d = JSON.parse(d)
                if (d.length == 1 && d[0].uuid == UID) {

                return 200;
                }
                else {
                return 500;
                }
                });
                });

                req.on('error', (e) => {
                console.error(e);
                });





                share|improve this answer













                after 2 days I find how to solve it, I used these code:



                var rootCas = require('ssl-root-cas/latest').create();
                rootCas.addFile(__dirname + './../../server/ssl/domain.crt');
                const https = require('https');//.globalAgent.options.ca = require('ssl-root-cas/latest').create();
                var request = require('request');


                and



                 const options = {
                hostname: 'app.mydomain.com',
                port: 443,
                path: '/api/uuids?filter[where][uuid]=' + UID,
                method: 'GET',
                key: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.key')),
                cert: fs.readFileSync(path.join(__dirname, './../../server/ssl/domain.crt'))
                };
                const req = https.get(options, (res) => {
                res.on('data', (d) => {
                d = JSON.parse(d)
                if (d.length == 1 && d[0].uuid == UID) {

                return 200;
                }
                else {
                return 500;
                }
                });
                });

                req.on('error', (e) => {
                console.error(e);
                });






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 1 at 7:14









                RSARSA

                6631925




                6631925






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984616%2funable-to-verify-the-first-certificate-in-nodejs-with-loopbackjs%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas