Skip to content

Commit

Permalink
change file permission for files written to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
taeyeong2k committed Sep 26, 2024
1 parent cd62faa commit 24aab8a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/api/submitForm/csrgenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function generateCsr(input: CsrData) {
.map((name, index) => `DNS.${index + 1} = ${name}`)
.join("\n");

console.log("sanEntries", sanEntries);
// console.log("sanEntries", sanEntries);
const configFileContent = csr_template
.replace("{Country}", country)
.replace("{State}", state)
Expand All @@ -70,7 +70,7 @@ export async function generateCsr(input: CsrData) {
.replace("{CN}", mainCN)
.replace("{alt_names_list}", sanEntries);

console.log("configFileContent", configFileContent);
console.log("configFileContent", configFileContent, { mode: 0o600 });
const configFilePath = path.join(
os.tmpdir(),
`temp_config_${Date.now()}.cnf`
Expand Down Expand Up @@ -105,5 +105,8 @@ export async function generateCsr(input: CsrData) {
return output;
} catch (e) {
console.error(`An exception occurred: ${e}`);
if (fs.existsSync(configFilePath)) fs.unlinkSync(configFilePath);
if (fs.existsSync(privateKeyPath)) fs.unlinkSync(privateKeyPath);
if (fs.existsSync(csrPath)) fs.unlinkSync(csrPath);
}
}

0 comments on commit 24aab8a

Please sign in to comment.