mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix issue on mac
This commit is contained in:
parent
a0adc131e5
commit
fc6b0b4b5e
1 changed files with 10 additions and 6 deletions
|
|
@ -169,18 +169,22 @@ export async function installSafeChainCA() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.writeInformation("Safe-chain: Installing CA certificate to system trust store.");
|
ui.writeInformation("Safe-chain: Installing CA certificate to trust store.");
|
||||||
ui.writeInformation("Safe-chain: You may be prompted for your password to authorize this installation.");
|
|
||||||
|
|
||||||
if (platform === OS_DARWIN) {
|
if (platform === OS_DARWIN) {
|
||||||
// macOS: use security CLI with sudo (will prompt for password)
|
// macOS: Install into user trust store
|
||||||
await safeSpawn("sudo", ["security", "add-trusted-cert", "-d", "-r", "trustRoot", "-k", DARWIN_CA_PATH, caPath], { stdio: "inherit" });
|
const securityCmd = ["add-trusted-cert", "-r", "trustRoot", caPath];
|
||||||
|
const result = await safeSpawn("security", securityCmd, { stdio: "inherit" });
|
||||||
|
if (result.status !== 0) {
|
||||||
|
throw new Error(`Failed to install CA certificate into user trust store (exit code ${result.status}).`);
|
||||||
|
}
|
||||||
|
ui.writeVerbose("Safe-chain: CA certificate installed in user trust settings (no admin prompt).");
|
||||||
} else if (platform === OS_LINUX) {
|
} else if (platform === OS_LINUX) {
|
||||||
// Linux: use update-ca-certificates with sudo (will prompt for password)
|
// Linux: use update-ca-certificates
|
||||||
await safeSpawn("sudo", ["cp", caPath, LINUX_CA_PATH], { stdio: "inherit" });
|
await safeSpawn("sudo", ["cp", caPath, LINUX_CA_PATH], { stdio: "inherit" });
|
||||||
await safeSpawn("sudo", ["update-ca-certificates"], { stdio: "inherit" });
|
await safeSpawn("sudo", ["update-ca-certificates"], { stdio: "inherit" });
|
||||||
} else if (platform === OS_WINDOWS) {
|
} else if (platform === OS_WINDOWS) {
|
||||||
// Windows: use certutil with UAC elevation prompt
|
// Windows: use certutil (with UAC elevation prompt)
|
||||||
const psCommand = `Start-Process -FilePath certutil -ArgumentList '-addstore','-f','Root','${caPath}' -Verb RunAs -Wait`;
|
const psCommand = `Start-Process -FilePath certutil -ArgumentList '-addstore','-f','Root','${caPath}' -Verb RunAs -Wait`;
|
||||||
await safeSpawn("powershell", ["-Command", psCommand], { stdio: "inherit" });
|
await safeSpawn("powershell", ["-Command", psCommand], { stdio: "inherit" });
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue