fix: correctly install tls certs with osascript

This commit is contained in:
James Houlahan 2020-04-17 16:25:01 +02:00
parent b75a6f7cf8
commit 8f8fbc745d
2 changed files with 9 additions and 7 deletions

View File

@ -17,6 +17,9 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
* GODT-124 bump go-appdir from v1.0.0 to v1.1.0
* CSB-72 Skip processing message update event if http statuscode is 422
### Fixed
* Use correct binary name when finding location of addcert.scpt
## [v1.2.6] Donghai - beta (2020-03-31)
### Added

View File

@ -29,11 +29,9 @@ import (
"net"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/kardianos/osext"
)
type tlsConfiger interface {
@ -74,10 +72,11 @@ func GetTLSConfig(cfg tlsConfiger) (tlsConfig *tls.Config, err error) {
if runtime.GOOS == "darwin" {
// If this fails, log the error but continue to load.
if p, err := osext.Executable(); err == nil {
p = strings.TrimSuffix(p, "MacOS/Desktop-Bridge") // This needs to match the executable name.
p += "Resources/addcert.scpt"
if err := exec.Command("/usr/bin/osascript", p).Run(); err != nil { // nolint[gosec]
if binaryPath, err := os.Executable(); err == nil {
macOSPath := filepath.Dir(binaryPath)
contentsPath := filepath.Dir(macOSPath)
resourcesPath := filepath.Join(contentsPath, "Resources", "addcert.scpt")
if err := exec.Command("/usr/bin/osascript", resourcesPath).Run(); err != nil { // nolint[gosec]
log.WithError(err).Error("Failed to add cert to system keychain")
}
}