How to use the pem.getModulus 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 DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
pem.createCertificate((error: any, data: any) => {
      const certificate = (data && data.certificate || '').toString();
      test.ifError(error);
      test.ok(certificate);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.getModulus(certificate, (error: any, data: any) => {
        const certmodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(certmodulus);
        test.ok(certmodulus.match(/^[0-9A-F]*$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);
        pem.getModulus(certificate, (error: any, data: any) => {
          const keymodulus = (data && data.modulus || '').toString();
          test.ifError(error);
          test.ok(keymodulus);
          test.ok(keymodulus.match(/^[0-9A-F]*$/));
          test.ok(keymodulus === certmodulus);
          // test.ok(fs.readdirSync('./tmp').length === 0);
          test.done();
        });
      });
    });
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.getModulus(certificate, (error: any, data: any) => {
      var certmodulus = (data && data.modulus || '').toString();
      test.ifError(error);
      test.ok(certmodulus);
      test.ok(certmodulus.match(/^[0-9A-F]*$/));
      // test.ok(fs.readdirSync('./tmp').length === 0);
      pem.getModulus(key, 'password', (error: any, data: any) => {
        var keymodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(keymodulus);
        test.ok(keymodulus.match(/^[0-9A-F]*$/));
        test.ok(keymodulus === certmodulus);
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.getModulus(certificate, (error: any, data: any) => {
        var certmodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(certmodulus);
        test.ok(certmodulus.match(/^[0-9A-F]*$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);
        pem.getModulus(certificate, (error: any, data: any) => {
          var keymodulus = (data && data.modulus || '').toString();
          test.ifError(error);
          test.ok(keymodulus);
          test.ok(keymodulus.match(/^[0-9A-F]*$/));
          test.ok(keymodulus === certmodulus);
          // test.ok(fs.readdirSync('./tmp').length === 0);
          test.done();
        });
      });
    });
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
'Get modulus from a protected key': (test: any) => {
    var certificate = ''; // fs.readFileSync('./test/fixtures/test.crt').toString();
    var key = ''; // fs.readFileSync('./test/fixtures/test.key').toString();

    pem.getModulus(certificate, (error: any, data: any) => {
      var certmodulus = (data && data.modulus || '').toString();
      test.ifError(error);
      test.ok(certmodulus);
      test.ok(certmodulus.match(/^[0-9A-F]*$/));
      // test.ok(fs.readdirSync('./tmp').length === 0);
      pem.getModulus(key, 'password', (error: any, data: any) => {
        var keymodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(keymodulus);
        test.ok(keymodulus.match(/^[0-9A-F]*$/));
        test.ok(keymodulus === certmodulus);
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
'Get modulus from a protected key': (test: any) => {
    const certificate = ''; // fs.readFileSync('./test/fixtures/test.crt').toString();
    const key = ''; // fs.readFileSync('./test/fixtures/test.key').toString();

    pem.getModulus(certificate, (error: any, data: any) => {
      const certmodulus = (data && data.modulus || '').toString();
      test.ifError(error);
      test.ok(certmodulus);
      test.ok(certmodulus.match(/^[0-9A-F]*$/));
      // test.ok(fs.readdirSync('./tmp').length === 0);
      pem.getModulus(key, 'password', (error: any, data: any) => {
        const keymodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(keymodulus);
        test.ok(keymodulus.match(/^[0-9A-F]*$/));
        test.ok(keymodulus === certmodulus);
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
  },
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
pem.getModulus(certificate, (error: any, data: any) => {
      const certmodulus = (data && data.modulus || '').toString();
      test.ifError(error);
      test.ok(certmodulus);
      test.ok(certmodulus.match(/^[0-9A-F]*$/));
      // test.ok(fs.readdirSync('./tmp').length === 0);
      pem.getModulus(key, 'password', (error: any, data: any) => {
        const keymodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(keymodulus);
        test.ok(keymodulus.match(/^[0-9A-F]*$/));
        test.ok(keymodulus === certmodulus);
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
  },
github jembi / openhim-core-js / src / api / keystore.js View on Github external
return KeystoreModelAPI.findOne((err, keystoreDoc) => {
    if (err) { return callback(err, null) }

    // if the key is encrypted but no passphrase is supplied, return  false instantly
    if (/Proc-Type:.*ENCRYPTED/.test(keystoreDoc.key) && ((keystoreDoc.passphrase == null) || (keystoreDoc.passphrase.length === 0))) {
      return callback(null, false)
    }

    return pem.getModulus(keystoreDoc.key, keystoreDoc.passphrase, (err, keyModulus) => {
      if (err) { return callback(err, null) }
      return pem.getModulus(keystoreDoc.cert.data, (err, certModulus) => {
        if (err) { return callback(err, null) }

        // if cert/key match and are valid
        if (keyModulus.modulus === certModulus.modulus) {
          return callback(null, true)
        } else {
          return callback(null, false)
        }
      })
    })
  })
}
github jembi / openhim-core-js / src / api / keystore.js View on Github external
return pem.getModulus(keystoreDoc.key, keystoreDoc.passphrase, (err, keyModulus) => {
      if (err) { return callback(err, null) }
      return pem.getModulus(keystoreDoc.cert.data, (err, certModulus) => {
        if (err) { return callback(err, null) }

        // if cert/key match and are valid
        if (keyModulus.modulus === certModulus.modulus) {
          return callback(null, true)
        } else {
          return callback(null, false)
        }
      })
    })
  })