Skip to content

Commit

Permalink
Remove certificates from the keychain using the systray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Apr 10, 2024
1 parent f5dcb39 commit 18d430b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions systray/systray_real.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ func (s *Systray) start() {
s.updateMenuItem(mRmCrashes, config.LogsIsEmpty())

mGenCerts := systray.AddMenuItem("Generate and Install HTTPS certificates", "HTTPS Certs")
mRemoveCerts := systray.AddMenuItem("Remove HTTPS certificates", "")
// On linux/windows chrome/firefox/edge(chromium) the agent works without problems on plain HTTP,
// so we disable the menuItem to generate/install the certificates
if runtime.GOOS != "darwin" {
s.updateMenuItem(mGenCerts, true)
s.updateMenuItem(mRemoveCerts, true)
} else {
s.updateMenuItem(mGenCerts, config.CertsExist())
// TODO: should we add a different check to disable the uninstall function?
s.updateMenuItem(mRemoveCerts, !config.CertsExist())
}

// Add pause/quit
Expand Down Expand Up @@ -103,6 +107,15 @@ func (s *Systray) start() {
cert.DeleteCertificates(certDir)
}
s.Restart()
case <-mRemoveCerts.ClickedCh:
err := cert.UninstallCertificates()
if err != nil {
log.Errorf("cannot uninstall certificates something went wrong: %s", err)
} else {
certDir := config.GetCertificatesDir()
cert.DeleteCertificates(certDir)
}
s.Restart()
case <-mPause.ClickedCh:
s.Pause()
case <-mQuit.ClickedCh:
Expand Down

0 comments on commit 18d430b

Please sign in to comment.