Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getAdminCryptoContentOfOrganization(org) {
let orgObject = this.network.organizations[org];
// if either is missing, the result is undefined
if (!CaliperUtils.checkAllProperties(orgObject, 'adminPrivateKey', 'signedCert')) {
return undefined;
}
let privateKey = orgObject.adminPrivateKey;
let signedCert = orgObject.signedCert;
let privateKeyPEM;
let signedCertPEM;
if (CaliperUtils.checkProperty(privateKey, 'path')) {
privateKeyPEM = fs.readFileSync(privateKey.path);
} else {
privateKeyPEM = privateKey.pem;
}
if (CaliperUtils.checkProperty(signedCert, 'path')) {
getClientCryptoContent(client) {
let clientObject = this.network.clients[client].client;
if (!CaliperUtils.checkAllProperties(clientObject, 'clientPrivateKey', 'clientSignedCert')) {
return undefined;
}
let privateKey = clientObject.clientPrivateKey;
let signedCert = clientObject.clientSignedCert;
let privateKeyPEM;
let signedCertPEM;
if (CaliperUtils.checkProperty(privateKey, 'path')) {
privateKeyPEM = fs.readFileSync(privateKey.path);
} else {
privateKeyPEM = privateKey.pem;
}
if (CaliperUtils.checkProperty(signedCert, 'path')) {
signedCertPEM = fs.readFileSync(signedCert.path);