How to use the pem.getPublicKey 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 auth0 / node-auth0 / test / auth / oauth-with-idtoken-validation.tests.js View on Github external
pem.createCertificate({ days: 1, selfSigned: true }, function(err, keys) {
    if (err) {
      throw err;
    }
    pem.getPublicKey(keys.certificate, function(e, p) {
      if (e) {
        throw e;
      }
      cb({ serviceKey: keys.serviceKey, certificate: keys.certificate, publicKey: p.publicKey });
    });
  });
};
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) {
					console.log(`could not import services ${this.publicKeyStr}`)
				}
			});
			pem.config({sync: false});
		}
		if (this.hasPrivateKey) {
			this.privateKeyNodeRsa = new NodeRsa();
			this.privateKeyNodeRsa.importKey(this.PRIVATE_KEY + " ", "private");
		}
	}
github apigee-internal / microgateway / cli / lib / upgrade-kvm.js View on Github external
}, function(err, res, body) {
        if (err) {
            writeConsoleLog('error',{component: CONSOLE_LOG_TAG_COMP},err);
        } else {
            writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},"Certificate found!");
            pem.getPublicKey(body, function(err, publicKey) {
                writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},publicKey.publicKey);
                var updatekvmuri = util.format("%s/v1/organizations/%s/environments/%s/keyvaluemaps/%s",
                    options.baseuri, options.org, options.env, options.kvm);
                var payload = {
                    "name": options.kvm,
                    "encrypted": "true",
                    "entry": [
                        {
                            "name": "private_key_kid",
                            "value": options.kid
                        },
                        {
                            "name": "public_key1",
                            "value": publicKey.publicKey
                        },
                        {
github apigee-internal / microgateway / cli / lib / cert-lib.js View on Github external
function uploadCert(options, managementUri, vaultName, privateKey, publicKey, callback) {
    const async = require('async');

    pem.getPublicKey(publicKey, function(err, key) {
        async.series(
            [
                function(cb) {
                    if (!options.force) {
                        return cb();
                    }
                    deleteVault(generateCredentialsObject(options), managementUri, options.org, options.env, vaultName, cb);
                },
                function(cb) {
                    writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'creating KVM');
                    writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'adding private_key');
                    writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'adding public_key');
                    var entries = [{
                            'name': 'private_key',
                            'value': privateKey
                        },
github apigee-internal / microgateway / cli / lib / rotate-key.js View on Github external
function(cb) {
					pem.getPublicKey(oldCertificate, function(e, oldPublicKey) {
						if (e) cb(e);
						else cb(null, oldPublicKey);
					});
					
				}, 
				function(cb) {