shell: rework code to use shell.spawn
spawn gives out streams and we have more control over the stdout/stderr buffers. otherwise, we have to provide a max buffer capture size to exec
This commit is contained in:
@@ -53,8 +53,8 @@ async function generateDkimKey() {
|
||||
const privateKeyFilePath = path.join(os.tmpdir(), `dkim-${crypto.randomBytes(4).readUInt32LE(0)}.private`);
|
||||
|
||||
// https://www.unlocktheinbox.com/dkim-key-length-statistics/ and https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-authentication-dkim-easy.html for key size
|
||||
await shell.exec(`openssl genrsa -out ${privateKeyFilePath} 1024`, {});
|
||||
await shell.exec(`openssl rsa -in ${privateKeyFilePath} -out ${publicKeyFilePath} -pubout -outform PEM`, {});
|
||||
await shell.spawn('openssl', ['genrsa', '-out', privateKeyFilePath, '1024'], {});
|
||||
await shell.spawn('openssl', ['rsa', '-in', privateKeyFilePath, '-out', publicKeyFilePath, '-pubout', '-outform', 'PEM'], {});
|
||||
|
||||
const publicKey = safe.fs.readFileSync(publicKeyFilePath, 'utf8');
|
||||
if (!publicKey) throw new BoxError(BoxError.FS_ERROR, safe.error.message);
|
||||
|
||||
Reference in New Issue
Block a user