Skip to content

Commit

Permalink
added proper warning regarding CA import
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouelie committed Jun 22, 2018
1 parent 4a49d54 commit c7b2026
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
38 changes: 23 additions & 15 deletions certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,30 @@ func addCAToMachine(eapType uint64, caFileBinary string, CERTUTIL_PROGRAM_PATH s
var err error
var ERROR_CANCELED int64
ERROR_CANCELED = 2147943623
sum := 0
addCA := exec.Command(CERTUTIL_PROGRAM_PATH, "-addstore", "-user", "Root", caFileBinary)
// use Start() and Wait() to specify exit status 1 error
addCA.Start()
// error handling
if err := addCA.Wait(); err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
for i := 0; i < 2; i++ {
runCommand := true
for runCommand {
runCommand = false
addCA := exec.Command(CERTUTIL_PROGRAM_PATH, "-addstore", "-user", "Root", caFileBinary)
// use Start() and Wait() instead of Run() to specify exit status 1 error
addCA.Start()
// error handling
if err := addCA.Wait(); err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
if status.ExitStatus() == int(ERROR_CANCELED) {
// reprompt user to add certificate to windows
walk.MsgBox(windowMsgBox, T("errorWindowTitle"), T("caErrorCanceled"), walk.MsgBoxOK)
os.Remove(caFileBinary)
os.Remove("profile.xml")
log.Fatal("Failed installing certificate: ", err)
sum += i
retryOrCancel := walk.MsgBox(windowMsgBox, T("errorWindowTitle"), T("caErrorCanceled"), walk.MsgBoxRetryCancel)
log.Println(retryOrCancel) // Retry = 4, Cancel = 2
if retryOrCancel == 4 {
log.Print("Failed installing certificate: ", err)
os.Remove(caFileBinary)
os.Remove("profile.xml")
runCommand = true
} else {
log.Fatal("Failed installing certificate: ", err)
os.Remove(caFileBinary)
os.Remove("profile.xml")
}
} else {
walk.MsgBox(windowMsgBox, T("errorWindowTitle"), T("cannotInstallCA"), walk.MsgBoxOK)
os.Remove(caFileBinary)
Expand All @@ -156,9 +164,9 @@ func addCAToMachine(eapType uint64, caFileBinary string, CERTUTIL_PROGRAM_PATH s
}
}
}
} else {
log.Println(T("successWindowTitle"), T("caInstallationSuccess"))
}
} else {
log.Println(T("successWindowTitle"), T("caInstallationSuccess"))
}
return err
}
4 changes: 2 additions & 2 deletions lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ENGLISH_TRANSLATION = `[
},
{
"id": "caErrorCanceled",
"translation": "The Certificate of Authority could not be installed on your machine.\nPlease select 'Yes' if prompted to install the Certificate of Authority."
"translation": "The Certificate of Authority could not be installed on your machine.\nIf you chose not to install the Certificate of Authority, the program will terminate."
},
{
"id": "cannotInstallCA",
Expand Down Expand Up @@ -242,7 +242,7 @@ const FRENCH_TRANSLATION = `[
},
{
"id": "caErrorCanceled",
"translation": "L'Autorité de Certification n'a pas pu être installée sur votre machine.\nVeuillez sélectionner «Oui» si vous êtes invité à installer l'Autorité de Certification'."
"translation": "L'Autorité de Certification n'a pas pu être installée sur votre machine.\nSi vous choisissez de ne pas l'installer, le programme se terminera."
},
{
"id": "cannotInstallCA",
Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func createLanguageFile(currentDir, translationLanguage, languageFileName string

// Converts base 64 background image to pf_bg.png
func base64ToPng(BACKGROUND_IMAGE_PF, tempPath string) (error, string) {
reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(BACKGROUND_IMAGE_PF))
reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(BACKGROUND_IMAGE_PF))
decodeBase64ToPng, _, err := image.Decode(reader)
if err != nil {
log.Fatal("Unable to decode base 64 background image: ", err)
}
//Encode from image format to writer
pngFilename := "pf_bg.png"
pngFilePath := tempPath + "\\" + pngFilename
pngFilePath := tempPath + "\\" + pngFilename
backgroundFile, err := os.Create(pngFilePath)
if err != nil {
log.Fatal("Unable to open or create background image: ", err)
Expand Down

0 comments on commit c7b2026

Please sign in to comment.