@@ -198,13 +198,14 @@ export async function generateCert(options?: CertOption): Promise<GenerateCertRe
198
198
}
199
199
}
200
200
201
- export async function addCertToSystemTrustStoreAndSaveCerts (
202
- cert : { certificate : string , privateKey : string } ,
203
- CAcert : string ,
204
- options ?: AddCertOption ,
205
- ) : Promise < string > {
201
+ interface Cert {
202
+ certificate : string
203
+ privateKey : string
204
+ }
205
+
206
+ export async function addCertToSystemTrustStoreAndSaveCerts ( cert : Cert , caCert : string , options ?: AddCertOption ) : Promise < string > {
206
207
const certPath = storeCert ( cert , options )
207
- const caCertPath = storeCACert ( CAcert , options )
208
+ const caCertPath = storeCACert ( caCert , options )
208
209
209
210
const platform = os . platform ( )
210
211
const args = 'TC, C, C'
@@ -241,24 +242,6 @@ export async function addCertToSystemTrustStoreAndSaveCerts(
241
242
242
243
log . info ( `Cert added to ${ folder } ` )
243
244
}
244
-
245
- // await runCommands([
246
- // `sudo cp ${certPath} /usr/local/share/ca-certificates/`,
247
-
248
- // // add new cert to system trust store
249
- // `certutil -d sql:${os.homedir()}/.pki/nssdb -A -t ${args} -n ${config.commonName} -i ${caCertPath}`,
250
-
251
- // // add new cert to system trust store for Brave
252
- // `certutil -d sql:${os.homedir()}/snap/brave/411/.pki/nssdb -A -t ${args} -n ${config.commonName} -i ${caCertPath}`,
253
-
254
- // // add new cert to system trust store for Firefox
255
- // `certutil -d sql:${os.homedir()}/snap/firefox/common/.mozilla/firefox/3l148raz.default -A -t ${args} -n ${config.commonName} -i ${caCertPath}`,
256
-
257
- // // reload system trust store
258
- // `sudo update-ca-certificates`,
259
- // ]).catch((err) => {
260
- // throw new Error(err)
261
- // })
262
245
}
263
246
else {
264
247
throw new Error ( `Unsupported platform: ${ platform } ` )
@@ -267,7 +250,7 @@ export async function addCertToSystemTrustStoreAndSaveCerts(
267
250
return certPath
268
251
}
269
252
270
- export function storeCert ( cert : { certificate : string , privateKey : string } , options ?: AddCertOption ) : string {
253
+ export function storeCert ( cert : Cert , options ?: AddCertOption ) : string {
271
254
// Construct the path using os.homedir() and path.join()
272
255
const certPath = options ?. customCertPath || config . certPath
273
256
const certKeyPath = options ?. customCertPath || config . keyPath
@@ -295,7 +278,7 @@ export function storeCert(cert: { certificate: string, privateKey: string }, opt
295
278
* @param options - The options for storing the CA Certificate
296
279
* @returns The path to the CA Certificate
297
280
*/
298
- export function storeCACert ( CAcert : string , options ?: AddCertOption ) : string {
281
+ export function storeCACert ( caCert : string , options ?: AddCertOption ) : string {
299
282
// Construct the path using os.homedir() and path.join()
300
283
const caCertPath = options ?. customCertPath || config . caCertPath
301
284
@@ -304,7 +287,7 @@ export function storeCACert(CAcert: string, options?: AddCertOption): string {
304
287
if ( ! fs . existsSync ( caCertDir ) )
305
288
fs . mkdirSync ( caCertDir , { recursive : true } )
306
289
307
- fs . writeFileSync ( caCertPath , CAcert )
290
+ fs . writeFileSync ( caCertPath , caCert )
308
291
309
292
return caCertPath
310
293
}
0 commit comments