How to use the pem.readCertificateInfo 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.createCSR((error: any, data: any) => {
      const csr = (data && data.csr || '').toString();
      test.ifError(error);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.readCertificateInfo(csr, (error: any, data: any) => {
        test.ifError(error);
        test.deepEqual(data, {
          issuer : {},
          country: '',
          state: '',
          locality: '',
          organization: '',
          organizationUnit: '',
          commonName: 'localhost',
          emailAddress: ''
        });
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
  },
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.createCSR({ csrConfigFile: './test/fixtures/test.cnf' }, (error: any, data: any) => {
      var csr = (data && data.csr || '').toString();
      test.ifError(error);
      test.ok(csr);
      test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
      test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));

      test.ok(data && data.clientKey);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.readCertificateInfo(csr, (error: any, data: any) => {
        test.ifError(error);
        test.deepEqual(data, certInfo);
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
  },
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(fs.readdirSync('./tmp').length === 0);

      pem.readCertificateInfo(certificate, (error: any, data: any) => {
        test.ifError(error);

        if (data.validity) {
          delete data.validity;
        }
        if (data.serial) {
          delete data.serial;
        }

        test.deepEqual(data, {
          issuer : {
            country: '',
            state: '',
            locality: '',
            organization: '',
            organizationUnit: '',
github beameio / beame-sdk / src / services / Credential.js View on Github external
initCryptoKeys() {
		if (this.hasKey("X509")) {
			pem.config({sync: true});
			pem.readCertificateInfo(this.getKey("X509") + "", (err, certData) => {
				if (this.fqdn && this.fqdn !== certData.commonName) {
					throw new Error(`Credentialing mismatch ${this.metadata} the common name in x509 does not match the metadata`);
				}
				this.certData = err ? null : certData;
				//noinspection JSUnresolvedVariable
				this.fqdn               = this.extractCommonName();
				this.beameStoreServices = new BeameStoreDataServices(this.fqdn);
				this._updateCertData();
			});

			pem.getPublicKey(this.getKey("X509") + "", (err, publicKey) => {
				this.publicKeyStr     = publicKey.publicKey;
				this.publicKeyNodeRsa = new NodeRsa();
				try {
					this.publicKeyNodeRsa.importKey(this.publicKeyStr, "pkcs8-public-pem");
				} catch (e) {
github smartdevicelink / sdl_server / app / v1 / helpers / certificates.js View on Github external
return new Promise((resolve, reject) => {
        pem.readCertificateInfo(cert, function (err, res) {
            if (err) {
                return reject(err);
            }
            return resolve(res);
        });
    });
}
github jembi / openhim-core-js / src / middleware / tlsAuthentication.js View on Github external
(cert =>
                  pem.readCertificateInfo(cert.data, (err, info) => {
                    if (err) {
                      return reject(err)
                    }

                    if (info.commonName === issuerCN) {
                      const promise = clientLookup(cert.fingerprint, info.commonName, info.issuer.commonName)
                      promise.then(resolve)
                    } else {
                      missedMatches++
                    }

                    if (missedMatches === keystore.ca.length) {
                      logger.info(`Issuer cn=${issuerCN} for cn=${subjectCN} not found in keystore.`)
                      return resolve(null)
                    }
                  }))(cert))