mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Fix WIndows shell + unit tests
This commit is contained in:
parent
1aef941d1c
commit
32c95dbb9d
14 changed files with 289 additions and 43 deletions
|
|
@ -2,12 +2,17 @@ import forge from "node-forge";
|
|||
import path from "path";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import { getSafeChainDir } from "../config/environmentVariables.js";
|
||||
|
||||
const certFolder = path.join(os.homedir(), ".safe-chain", "certs");
|
||||
const ca = loadCa();
|
||||
|
||||
const certCache = new Map();
|
||||
|
||||
function getCertFolder() {
|
||||
const safeChainDir = getSafeChainDir() ?? path.join(os.homedir(), ".safe-chain");
|
||||
return path.join(safeChainDir, "certs");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {forge.pki.PublicKey} publicKey
|
||||
* @returns {string}
|
||||
|
|
@ -20,7 +25,7 @@ function createKeyIdentifier(publicKey) {
|
|||
}
|
||||
|
||||
export function getCaCertPath() {
|
||||
return path.join(certFolder, "ca-cert.pem");
|
||||
return path.join(getCertFolder(), "ca-cert.pem");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,6 +117,7 @@ export function generateCertForHost(hostname) {
|
|||
}
|
||||
|
||||
function loadCa() {
|
||||
const certFolder = getCertFolder();
|
||||
const keyPath = path.join(certFolder, "ca-key.pem");
|
||||
const certPath = path.join(certFolder, "ca-cert.pem");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue