You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix buttons and improve handling of certificates when Safari is not the default browser (#949)
* Fix check on buttons returning the correct message
* Update certificates regardless of the default browser
* Set installCerts when the certificate is installed from previous versions of the Agent regardless of the default browser
* Do not set installCerts to false if the default browser is not Safari
* Do not ask again to update the certificate if the user refuses once
* Fix user script on macOS
* Check for the presence of the certificate in the keychain to determine if it is installed
* Fix getExpirationDate breaking when the certificate is expired
* Fix return value in case of error
* getExpirationDate rewritten to use the correct expiration field.
* Separate osascript default button from the one to press
* Fix leftover buttons
* Small text fixes in the "manage certificate" dialog
* Simplify error management in getExpirationDate
* Fix compiler warnings and move obj-c code into a separate file.
* certInKeychain returns a bool
* Fix building errors caused by objective-c files on Ubuntu and Windows
* Build objective-c files only on Darwin
* Remove -ld_classic library because XCode is not up to date on the CI
---------
Co-authored-by: Xayton <[email protected]>
// isExpired checks if a certificate is expired or about to expire (less than 1 month)
274
-
funcisExpired() (bool, error) {
270
+
// IsExpired checks if a certificate is expired or about to expire (less than 1 month)
271
+
funcIsExpired() (bool, error) {
275
272
bound:=time.Now().AddDate(0, 1, 0)
276
-
dateS, err:=GetExpirationDate()
273
+
date, err:=GetExpirationDate()
277
274
iferr!=nil {
278
275
returnfalse, err
279
276
}
280
-
date, _:=time.Parse(time.DateTime, dateS)
281
277
returndate.Before(bound), nil
282
278
}
283
279
284
-
// PromptInstallCertsSafari prompts the user to install the HTTPS certificates if they are using Safari
285
-
funcPromptInstallCertsSafari() bool {
286
-
buttonPressed:=utilities.UserPrompt("display dialog \"The Arduino Agent needs a local HTTPS certificate to work correctly with Safari.\nIf you use Safari, you need to install it.\" buttons {\"Do not install\", \"Install the certificate for Safari\"} default button 2 with title \"Arduino Agent: Install certificate\"")
287
-
returnstrings.Contains(string(buttonPressed), "button returned:Install the certificate for Safari")
288
-
}
289
-
290
-
// PromptExpiredCerts prompts the user to update the HTTPS certificates if they are using Safari
291
-
funcPromptExpiredCerts(certDir*paths.Path) {
292
-
ifexpired, err:=isExpired(); err!=nil {
293
-
log.Errorf("cannot check if certificates are expired something went wrong: %s", err)
294
-
} elseifexpired {
295
-
buttonPressed:=utilities.UserPrompt("display dialog \"The Arduino Agent needs a local HTTPS certificate to work correctly with Safari.\nYour certificate is expired or close to expiration. Do you want to update it?\" buttons {\"Do not update\", \"Update the certificate for Safari\"} default button 2 with title \"Arduino Agent: Update certificate\"")
296
-
ifstrings.Contains(string(buttonPressed), "button returned:Update the certificate for Safari") {
297
-
err:=UninstallCertificates()
298
-
iferr!=nil {
299
-
log.Errorf("cannot uninstall certificates something went wrong: %s", err)
300
-
} else {
301
-
DeleteCertificates(certDir)
302
-
GenerateAndInstallCertificates(certDir)
303
-
}
304
-
}
305
-
}
306
-
}
307
-
308
280
// GenerateAndInstallCertificates generates and installs the certificates
0 commit comments