Skip to content

Commit 97bfc48

Browse files
Install certificates if they are missing and the flag inside the config is set to true
1 parent 9690016 commit 97bfc48

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

main.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,21 @@ func loop() {
378378

379379
// check if the HTTPS certificates are expired and prompt the user to update them on macOS
380380
if runtime.GOOS == "darwin" {
381-
if *installCerts && config.CertsExist() {
382-
cert.PromptExpiredCerts(config.GetCertificatesDir())
381+
if *installCerts {
382+
if config.CertsExist() {
383+
cert.PromptExpiredCerts(config.GetCertificatesDir())
384+
} else {
385+
// installing the certificates from scratch at this point should only happen if
386+
// 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+
}
395+
}
383396
}
384397
}
385398

0 commit comments

Comments
 (0)