Skip to content

Commit 8804978

Browse files
Obtain certificates info using the systray icon
1 parent f492802 commit 8804978

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

systray/systray_real.go

+16
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package systray
2121

2222
import (
2323
"os"
24+
"os/exec"
2425
"runtime"
2526

2627
"fyne.io/systray"
@@ -65,11 +66,13 @@ func (s *Systray) start() {
6566

6667
mGenCerts := systray.AddMenuItem("Generate and Install HTTPS certificates", "HTTPS Certs")
6768
mRemoveCerts := systray.AddMenuItem("Remove HTTPS certificates", "")
69+
mCertsInfo := systray.AddMenuItem("Show HTTPS certificates info", "")
6870
// On linux/windows chrome/firefox/edge(chromium) the agent works without problems on plain HTTP,
6971
// so we disable the menuItem to generate/install the certificates
7072
if runtime.GOOS != "darwin" {
7173
s.updateMenuItem(mGenCerts, true)
7274
s.updateMenuItem(mRemoveCerts, true)
75+
s.updateMenuItem(mCertsInfo, true)
7376
} else {
7477
s.updateMenuItem(mGenCerts, config.CertsExist())
7578
s.updateMenuItem(mRemoveCerts, !config.CertsExist())
@@ -115,6 +118,19 @@ func (s *Systray) start() {
115118
cert.DeleteCertificates(certDir)
116119
}
117120
s.Restart()
121+
case <-mCertsInfo.ClickedCh:
122+
infoMsg := "The Arduino Agent needs a local HTTPS certificate to work correctly with Safari.\n\nYour HTTPS certificate status:\n"
123+
if config.CertsExist() {
124+
expDate, err := cert.GetExpirationDate()
125+
if err != nil {
126+
log.Errorf("cannot get certificates expiration date, something went wrong: %s", err)
127+
}
128+
infoMsg = infoMsg + "- Certificate installed: Yes\n- Certificate trusted: Yes\n- Certificate expiration date: " + expDate
129+
} else {
130+
infoMsg = infoMsg + "- Certificate installed: No\n- Certificate trusted: N/A\n- Certificate expiration date: N/A"
131+
}
132+
oscmd := exec.Command("osascript", "-e", "display dialog \""+infoMsg+"\" buttons \"OK\" with title \"Arduino Agent: certificates info\"")
133+
_ = oscmd.Run()
118134
case <-mPause.ClickedCh:
119135
s.Pause()
120136
case <-mQuit.ClickedCh:

0 commit comments

Comments
 (0)