Skip to content

Commit f7d9772

Browse files
committed
add menu option to generate the certs only if they are not present
1 parent 14dfc2b commit f7d9772

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

config/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ func GetCertificatesDir() *paths.Path {
2929
return GetDataDir()
3030
}
3131

32+
// CertsExist checks if the certs have already been generated
33+
func CertsExist() bool {
34+
certFile := GetCertificatesDir().Join("cert.pem")
35+
return certFile.Exist() //if the certFile is not present we assume there are no certs
36+
}
37+
3238
// GetDataDir returns the full path to the default Arduino Create Agent data directory.
3339
func GetDataDir() *paths.Path {
3440
userDir, err := os.UserHomeDir()

systray/systray_real.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import (
2424

2525
log "github.com/sirupsen/logrus"
2626

27+
cert "github.com/arduino/arduino-create-agent/certificates"
2728
"github.com/arduino/arduino-create-agent/config"
29+
2830
"github.com/arduino/arduino-create-agent/icon"
2931
"github.com/getlantern/systray"
3032
"github.com/go-ini/ini"
@@ -62,6 +64,9 @@ func (s *Systray) start() {
6264
mRmCrashes := systray.AddMenuItem("Remove crash reports", "")
6365
s.updateMenuItem(mRmCrashes, config.LogsIsEmpty())
6466

67+
mGenCerts := systray.AddMenuItem("Generate HTTPS certificates", "HTTPS Certs")
68+
s.updateMenuItem(mGenCerts, config.CertsExist())
69+
6570
// Add pause/quit
6671
mPause := systray.AddMenuItem("Pause Agent", "")
6772
systray.AddSeparator()
@@ -83,6 +88,9 @@ func (s *Systray) start() {
8388
case <-mRmCrashes.ClickedCh:
8489
s.RemoveCrashes()
8590
s.updateMenuItem(mRmCrashes, config.LogsIsEmpty())
91+
case <-mGenCerts.ClickedCh:
92+
cert.GenerateCertificates(config.GetCertificatesDir())
93+
s.Restart()
8694
case <-mPause.ClickedCh:
8795
s.Pause()
8896
case <-mQuit.ClickedCh:

0 commit comments

Comments
 (0)