Skip to content

Commit 562e339

Browse files
committed
feat: add basePath option
1 parent 3c1cb49 commit 562e339

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Diff for: src/certificate.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ export async function addCertToSystemTrustStoreAndSaveCert(cert: Cert, caCert: s
257257

258258
export function storeCertificate(cert: Cert, options?: TlsOption): CertPath {
259259
debugLog('storage', `Storing certificate and private key with options: ${JSON.stringify(options)}`, options?.verbose)
260-
const certPath = options?.certPath || config.certPath
261-
const certKeyPath = options?.keyPath || config.keyPath
260+
const certPath = options?.basePath ? path.join(options.basePath, options?.certPath || config.certPath) : config.certPath
261+
const certKeyPath = options?.basePath ? path.join(options.basePath, options?.keyPath || config.keyPath) : config.keyPath
262262

263263
debugLog('storage', `Certificate path: ${certPath}`, options?.verbose)
264264
debugLog('storage', `Private key path: ${certKeyPath}`, options?.verbose)
@@ -295,7 +295,7 @@ export function storeCertificate(cert: Cert, options?: TlsOption): CertPath {
295295
*/
296296
export function storeCACertificate(caCert: string, options?: TlsOption): CertPath {
297297
debugLog('storage', 'Storing CA certificate', options?.verbose)
298-
const caCertPath = options?.caCertPath || config.caCertPath
298+
const caCertPath = options?.basePath ? path.join(options.basePath, options?.caCertPath || config.caCertPath) : config.caCertPath
299299

300300
debugLog('storage', `CA certificate path: ${caCertPath}`, options?.verbose)
301301

Diff for: src/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const config: TlsConfig = await loadConfig({
1818
hostCertCN: 'stacks.localhost',
1919
domain: 'stacks.localhost',
2020
rootCA: { certificate: '', privateKey: '' },
21+
basePath: '',
2122
caCertPath: path.join(os.homedir(), '.stacks', 'ssl', `stacks.localhost.ca.crt`),
2223
certPath: path.join(os.homedir(), '.stacks', 'ssl', `stacks.localhost.crt`),
2324
keyPath: path.join(os.homedir(), '.stacks', 'ssl', `stacks.localhost.crt.key`),

Diff for: src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface TlsConfig {
99
stateName: string
1010
localityName: string
1111
commonName: string
12+
basePath: string
1213
keyPath: string
1314
certPath: string
1415
caCertPath: string

0 commit comments

Comments
 (0)