Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
});
},
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();
});
});
},
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: '',
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) {
return new Promise((resolve, reject) => {
pem.readCertificateInfo(cert, function (err, res) {
if (err) {
return reject(err);
}
return resolve(res);
});
});
}
(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))