Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, (error: any, csr: any) => {
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', (err: any, pkcs12: any) => {
test.ifError(err);
test.ok(pkcs12);
// test.ok(fs.readdirSync('./tmp').length === 0);
test.done();
});
});
});
}, (error: any, cert: any) => {
test.ifError(error);
pem.createPkcs12(cert.clientKey, cert.certificate, '', {certFiles: [ca.certificate]}, (error: any, pkcs12: any) => {
test.ifError(error);
test.ok(pkcs12.pkcs12);
// test.ok(fs.readdirSync('./tmp').length === 0);
pem.readPkcs12(pkcs12.pkcs12, (error: any, keystore: any) => {
test.ifError(error);
test.ok(keystore);
test.equal(ca.certificate, keystore.ca[0]);
test.equal(cert.certificate, keystore.cert);
test.equal(cert.clientKey, keystore.key);
test.done();
});
});
}, (error: any, cert: any) => {
test.ifError(error);
pem.createPkcs12(cert.clientKey, cert.certificate, '', {certFiles: [ca.certificate]}, (error: any, pkcs12: any) => {
test.ifError(error);
test.ok(pkcs12.pkcs12);
// test.ok(fs.readdirSync('./tmp').length === 0);
const pkcs12Buffer = new Buffer(pkcs12.pkcs12);
pem.readPkcs12(pkcs12Buffer, (error: any, keystore: pem.Pkcs12ReadResult) => {
test.ifError(error);
test.ok(keystore);
test.equal(ca.certificate, keystore.ca[0]);
test.equal(cert.certificate, keystore.cert);
test.equal(cert.clientKey, keystore.key);
});
const pkcs12File: string = __dirname + '/test.pkcs12';
}, (error: any, csr: any) => {
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', (err: any, pkcs12: any) => {
test.ifError(err);
test.ok(pkcs12);
// test.ok(fs.readdirSync('./tmp').length === 0);
test.done();
});
});
});
return new Promise((resolve, reject) => {
pem.createPkcs12(
clientKey,
certificate,
settings.securityOptions.passphrase,
function (err, pkcs12) {
if (err) {
return reject(err);
}
return resolve(pkcs12);
}
);
});
}
cred.getCert(sign, keys.pubKeys, {validityPeriod, saveCerts: false}).then(payload => {
if (!payload) {
reject(`invalid cert request payload`);
return;
}
const pem = require('pem');
pem.createPkcs12(private_key, payload.p7b, password, [], (err, pfx) => {
if (err) {
reject(err);
return;
}
resolve({
fqdn,
pfx: pfx.pkcs12
});
});
}).catch(onError);
}).catch(onError);
function checkAuthorityValidity (cb){
if (!openSSLEnabled) {
return cb(false);
}
pem.createPkcs12(
authorityKey,
authorityCertificate,
settings.securityOptions.passphrase,
{
cipher: 'aes128',
clientKeyPassword: settings.securityOptions.passphrase
},
function(err, pkcs12){
cb((err) ? false : true);
}
);
}