better error messages

This commit is contained in:
Girish Ramakrishnan
2021-05-04 10:45:36 -07:00
parent 5ab925e284
commit 7d8d6d4913
2 changed files with 2 additions and 3 deletions
+2 -2
View File
@@ -51,7 +51,7 @@ async function initSecrets() {
let value = await get(exports.ACME_ACCOUNT_KEY);
if (!value) {
const accountKeyPem = safe.child_process.execSync('openssl genrsa 4096');
if (!accountKeyPem) throw new BoxError(BoxError.OPENSSL_ERROR, safe.error);
if (!accountKeyPem) throw new BoxError(BoxError.OPENSSL_ERROR, `Could not generate acme account key: ${safe.error.message}`);
await set(exports.ACME_ACCOUNT_KEY, accountKeyPem);
}
@@ -77,7 +77,7 @@ async function initSecrets() {
safe.fs.unlinkSync(`${paths.SFTP_KEYS_DIR}/ssh_host_rsa_key.pub`);
safe.fs.unlinkSync(`${paths.SFTP_KEYS_DIR}/ssh_host_rsa_key`);
}
if (!safe.child_process.execSync(`ssh-keygen -m PEM -t rsa -f "${paths.SFTP_KEYS_DIR}/ssh_host_rsa_key" -q -N ""`)) throw new BoxError(BoxError.OPENSSL_ERROR, safe.error);
if (!safe.child_process.execSync(`ssh-keygen -m PEM -t rsa -f "${paths.SFTP_KEYS_DIR}/ssh_host_rsa_key" -q -N ""`)) throw new BoxError(BoxError.OPENSSL_ERROR, `Could not generate sftp ssh keys: ${safe.error.message}`);
const publicKey = safe.fs.readFileSync(`${paths.SFTP_KEYS_DIR}/ssh_host_rsa_key.pub`);
await set(exports.SFTP_PUBLIC_KEY, publicKey);
const privateKey = safe.fs.readFileSync(`${paths.SFTP_KEYS_DIR}/ssh_host_rsa_key`);