How to use the pem.config 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 beameio / beame-insta-ssl / cli / beame.js View on Github external
function main() {
	let cmdName, subCmdName, cmd;

	if (pem.version) {
		pem.config({sync: true});
		pem.version((err, data) => {
			if (err) {
				throw Error("Could not run openssl. beame-insta-ssl requires openssl. Please make sure openssl is installed and is in PATH");
			}
		});
		pem.config({sync: false});
	} else {
		if (!process.env.BEAME_NO_PEM_WARNING) {
			logger.info("WARNING: Using 'pem' module without 'config' function. Not checking for openssl availability.");
		}
	}

	// getHelpMessage() is only defined in this file.
	commands.creds.getCreds.toText = (metadata) => `Certificate created! Certificate FQDN is ${metadata.fqdn}\n\n` + getHelpMessage('certificate-created.txt');

	// Old CLI compatibility - start
github beameio / beame-sdk / src / services / Credential.js View on Github external
//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 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");
github beameio / beame-sdk / src / services / Credential.js View on Github external
initFromX509(x509, metadata) {
		pem.config({sync: true});
		pem.readCertificateInfo(x509, (err, certData) => {
			assert(!err, err);
			this.certData = certData;
			this.beameStoreServices = new BeameStoreDataServices(certData.commonName);
			this.metadata.fqdn = certData.commonName;
			this.fqdn = certData.commonName;
			this.beameStoreServices.writeObject(Config.CertFileNames.X509, x509);
			this._updateCertData();

		});
		pem.getPublicKey(x509, (err, publicKey) => {
			assert(!err, err);
			this.publicKeyStr = publicKey.publicKey;
			this.publicKeyNodeRsa = new NodeRsa();
			try {
				this.publicKeyNodeRsa.importKey(this.publicKeyStr, "pkcs8-public-pem");