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

      pem.getFingerprint(certificate, (error: any, data: any) => {
        var fingerprint = (data && data.fingerprint || '').toString();
        test.ifError(error);
        test.ok(fingerprint);
        test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);

        test.done();
      });
    });
  },
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.getFingerprint(certificate, (error: any, data: any) => {
        const fingerprint = (data && data.fingerprint || '').toString();
        test.ifError(error);
        test.ok(fingerprint);
        test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);

        test.done();
      });
    });
  },
github jembi / openhim-core-js / src / upgradeDB.js View on Github external
KeystoreModel.findOne((err, keystore) => {
        if (err) { return reject(err) }
        if (!keystore) { return resolve() }

        // convert server cert
        pem.getFingerprint(keystore.cert.data, (err, obj) => {
          if (err) { return reject(err) }
          keystore.cert.fingerprint = obj.fingerprint

          const promises = keystore.ca.map((cert) => {
            return new Promise((resolve, reject) => {
              pem.getFingerprint(cert.data, (err, obj) => {
                if (err) { return reject(err) }
                cert.fingerprint = obj.fingerprint
                return resolve()
              })
            })
          })

          Promise.all(promises).then(() =>
            keystore.save((err) => {
              if (err != null) { logger.error(`Failed to save keystore: ${err}`) }
github Azure / azure-iot-sdk-node / build / tools / create_device_certs.js View on Github external
pem.createCertificate(certOptions, function (err, result) {
    if (err) {
      done(err);
    } else {
      fs.writeFileSync(certFile, result.certificate);
      fs.writeFileSync(keyFile, result.clientKey);
      pem.getFingerprint(result.certificate, function (err, result) {
        thumbprint = result.fingerprint.replace(/:/g, '');

        var deviceDescription = {
          deviceId: argv.deviceId,
          status: 'enabled',
          authentication: {
            x509Thumbprint: {
              primaryThumbprint: thumbprint
            }
          }
        };

        registry.create(deviceDescription, function (err, deviceInfo) {
          if(!!err) {
            console.log(chalk.red('Could not create device: ' + err.message + '\n' + err.responseBody));
            process.exit(1);
github tableflip / guvnor / lib / daemon / lib / find-user-with-certificate.js View on Github external
function getFingerprint (keys, next) {
      pem.getFingerprint(keys.cert, next)
    },
    function gotFingerprint (result, next) {
github Azure / iothub-explorer / iothub-explorer-create.js View on Github external
pem.createCertificate(certOptions, function (err, result) {
    if (err) {
      inputError('You must have OpenSSL installed in your path for iothub-explorer to be able to generate x509 certificates');
    } else {
      fs.writeFileSync(certFile, result.certificate);
      fs.writeFileSync(keyFile, result.clientKey);
      printSuccess('Certificate File: ' + certFile);
      printSuccess('Key File: ' + keyFile);
      pem.getFingerprint(result.certificate, function (err, result) {
        thumbprint = result.fingerprint.replace(/:/g, '');
        deviceInfo.authentication = {
          x509Thumbprint: {
            primaryThumbprint: thumbprint
          }
        };
        createDevice(deviceInfo);
      });
    }
  });
}
github tableflip / guvnor / lib / process-operations / systemd / list-process-certificate-fingerprints.js View on Github external
async.map(services, function getFingerprint (service, done) {
        pem.getFingerprint(service.env.GUVNOR_CERT, function gotFingerprint (error, fingerprint) {
          if (!error) {
            output[fingerprint.fingerprint] = {
              name: service.Unit.Description,
              script: service.env.GUVNOR_SCRIPT,
              status: 'unknown',
              user: service.Service.User,
              group: service.Service.Group
            }
          } else {
            logger.warn(service.Unit.Description, 'had an invalid certificate')
          }

          done()
        })
      }, function foundCertificateFingerprints (error) {
        next(error, output)
github jembi / openhim-core-js / src / server.js View on Github external
pem.readCertificateInfo(cert, (err, certInfo) => {
        if (err) {
          logger.error(err.stack)
          return callback(err)
        }
        return pem.getFingerprint(cert, (err, fingerprint) => {
          if (err) {
            logger.error(err.stack)
            return callback(err)
          }
          certInfo.data = cert
          certInfo.fingerprint = fingerprint.fingerprint
          return callback(certInfo)
        })
      })