File tree 3 files changed +16
-31
lines changed
3 files changed +16
-31
lines changed Original file line number Diff line number Diff line change @@ -302,14 +302,19 @@ func PromptExpiredCerts(certDir *paths.Path) {
302
302
log .Errorf ("cannot uninstall certificates something went wrong: %s" , err )
303
303
} else {
304
304
DeleteCertificates (certDir )
305
- GenerateCertificates (certDir )
306
- err := InstallCertificate (certDir .Join ("ca.cert.cer" ))
307
- // if something goes wrong during the cert install we remove them, so the user is able to retry
308
- if err != nil {
309
- log .Errorf ("cannot install certificates something went wrong: %s" , err )
310
- DeleteCertificates (certDir )
311
- }
305
+ GenerateAndInstallCertificates (certDir )
312
306
}
313
307
}
314
308
}
315
309
}
310
+
311
+ // GenerateAndInstallCertificates generates and installs the certificates
312
+ func GenerateAndInstallCertificates (certDir * paths.Path ) {
313
+ GenerateCertificates (certDir )
314
+ err := InstallCertificate (certDir .Join ("ca.cert.cer" ))
315
+ // if something goes wrong during the cert install we remove them, so the user is able to retry
316
+ if err != nil {
317
+ log .Errorf ("cannot install certificates something went wrong: %s" , err )
318
+ DeleteCertificates (certDir )
319
+ }
320
+ }
Original file line number Diff line number Diff line change @@ -237,14 +237,7 @@ func loop() {
237
237
if err != nil {
238
238
log .Panicf ("config.ini cannot be parsed: %s" , err )
239
239
}
240
- certDir := config .GetCertificatesDir ()
241
- cert .GenerateCertificates (certDir )
242
- err := cert .InstallCertificate (certDir .Join ("ca.cert.cer" ))
243
- // if something goes wrong during the cert install we remove them, so the user is able to retry
244
- if err != nil {
245
- log .Errorf ("cannot install certificates something went wrong: %s" , err )
246
- cert .DeleteCertificates (certDir )
247
- }
240
+ cert .GenerateAndInstallCertificates (config .GetCertificatesDir ())
248
241
} else {
249
242
err = config .SetInstallCertsIni (configPath .String (), "false" )
250
243
if err != nil {
@@ -384,14 +377,7 @@ func loop() {
384
377
} else {
385
378
// installing the certificates from scratch at this point should only happen if
386
379
// 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
- }
380
+ cert .GenerateAndInstallCertificates (config .GetCertificatesDir ())
395
381
}
396
382
}
397
383
}
Original file line number Diff line number Diff line change @@ -109,14 +109,8 @@ func (s *Systray) start() {
109
109
}
110
110
pressedButton := utilities .UserPrompt ("display dialog \" " + infoMsg + "\" buttons " + buttons + " with title \" Arduino Agent: manage HTTPS certificates\" " )
111
111
if strings .Contains (pressedButton , "Install certificate for Safari" ) {
112
- cert .GenerateCertificates (certDir )
113
- err := cert .InstallCertificate (certDir .Join ("ca.cert.cer" ))
114
- // if something goes wrong during the cert install we remove them, so the user is able to retry
115
- if err != nil {
116
- log .Errorf ("cannot install certificates something went wrong: %s" , err )
117
- cert .DeleteCertificates (certDir )
118
- }
119
- err = config .SetInstallCertsIni (s .currentConfigFilePath .String (), "true" )
112
+ cert .GenerateAndInstallCertificates (certDir )
113
+ err := config .SetInstallCertsIni (s .currentConfigFilePath .String (), "true" )
120
114
if err != nil {
121
115
log .Errorf ("cannot set installCerts value in config.ini: %s" , err )
122
116
}
You can’t perform that action at this time.
0 commit comments