Skip to content

Commit ea2c6a2

Browse files
Install certificates if they are missing and the flag inside the config is set to true
1 parent 9690016 commit ea2c6a2

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

main.go

+20-2
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,26 @@ func loop() {
378378

379379
// check if the HTTPS certificates are expired and prompt the user to update them on macOS
380380
if runtime.GOOS == "darwin" {
381-
if *installCerts && config.CertsExist() {
382-
cert.PromptExpiredCerts(config.GetCertificatesDir())
381+
if *installCerts {
382+
if config.CertsExist() {
383+
cert.PromptExpiredCerts(config.GetCertificatesDir())
384+
} else if cert.PromptInstallCertsSafari() {
385+
// installing the certificates from scratch at this point should only happen if
386+
// something went wrong during previous installation attempts
387+
certDir := config.GetCertificatesDir()
388+
cert.GenerateCertificates(certDir)
389+
err := cert.InstallCertificate(certDir.Join("ca.cert.cer"))
390+
// if something goes wrong during the cert install we remove them, so the user is able to retry
391+
if err != nil {
392+
log.Errorf("cannot install certificates something went wrong: %s", err)
393+
cert.DeleteCertificates(certDir)
394+
}
395+
} else {
396+
err = config.SetInstallCertsIni(configPath.String(), "false")
397+
if err != nil {
398+
log.Panicf("config.ini cannot be parsed: %s", err)
399+
}
400+
}
383401
}
384402
}
385403

0 commit comments

Comments
 (0)