How to use the pem.verifySigningChain function in pem

To help you get started, we’ve selected a few pem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotauth / iotauth / entity / node / accessors / node_modules / iotAuthService.js View on Github external
var ret = common.parseStringParam(migrationResp.authToken, 0);
        var authCert = ret.str;
        var cert = x509.parseCert(authCert);
        console.log(util.inspect(cert));
        //console.log(options.currentAuthPublicKey.toString());
        //console.log(x509.parseCert(options.currentAuthPublicKey.toString()));

        // verify certificate
        var caCert = fs.readFileSync('../../../auth/credentials/ca/CACert.pem');
        var trustedCertificateList = [];
        for (var i = 0; i < options.trustedAuthPublicKeyList.length; i++) {
            trustedCertificateList.push(options.trustedAuthPublicKeyList.toString());
        }
        trustedCertificateList.push(caCert.toString());
        pem.verifySigningChain(authCert.toString(),
            trustedCertificateList,
            // this callback brings about the verification result
            function(err, result) {
                console.log(err);
                console.log(result);
            if (result != true) {
                helperEventHandlers.onError('Certificate of new Auth is NOT verified!');
                return;
            }
            console.log('Certificate of new Auth is verified!');
            var authCertSubject = x509.getSubject(authCert);
            if (authCertSubject.organizationalUnitName != 'Auth' + migrationResp.authId) {
                helperEventHandlers.onError('Subject information does NOT match Auth ID!');
                return;
            }
            console.log('Subject information matches Auth ID!');
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
}, (error: any, cert: any) => {
          test.ifError(error);

          pem.verifySigningChain(cert.certificate, [intermediate.certificate], (error: any, valid: any) => {
            test.ifError(error);
            test.ok(valid === false);

            test.done();
          });
        });
      });
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
}, (error: any, cert: any) => {
        test.ifError(error);

        pem.verifySigningChain(cert.certificate, ca.certificate, (error: any, valid: any) => {
          test.ifError(error);
          test.ok(valid === true);

          test.done();
        });
      });
    });
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
}, (error: any, cert: any) => {
          test.ifError(error);

          pem.verifySigningChain(cert.certificate, [ca.certificate, intermediate.certificate], (error: any, valid: any) => {
            test.ifError(error);
            test.ok(valid === true);

            test.done();
          });
        });
      });
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
}, (error: any, cert: any) => {
        test.ifError(error);

        pem.verifySigningChain(cert.certificate, ca.certificate, (error: any, valid: any) => {
          test.ifError(error);
          test.ok(valid === true);

          test.done();
        });
      });
    });