From 87fa0301b34fec2501aafb2c8a0266052db0dc1b Mon Sep 17 00:00:00 2001 From: chrichts <84300304+chrichts@users.noreply.github.com> Date: Wed, 1 Sep 2021 22:48:55 +0800 Subject: [PATCH] Add functionality to provide cert for windows agent (#1818) * Adding certificate functionality to windows agent * Update windows template To allow for --fleet-certificate parameter when building windows agent * Gofmt -ed Windows.go * Gofmted windows.go again Replace space indentation with tab --- orbit/pkg/packaging/windows.go | 6 ++++++ orbit/pkg/packaging/windows_templates.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/orbit/pkg/packaging/windows.go b/orbit/pkg/packaging/windows.go index 223bb70394..969fb41942 100644 --- a/orbit/pkg/packaging/windows.go +++ b/orbit/pkg/packaging/windows.go @@ -56,6 +56,12 @@ func BuildMSI(opt Options) error { return errors.Wrap(err, "write enroll secret") } + if opt.FleetCertificate != "" { + if err := writeCertificate(opt, orbitRoot); err != nil { + return errors.Wrap(err, "write fleet certificate") + } + } + if err := writeWixFile(opt, tmpDir); err != nil { return errors.Wrap(err, "write wix file") } diff --git a/orbit/pkg/packaging/windows_templates.go b/orbit/pkg/packaging/windows_templates.go index a0e9bf9290..053b87e074 100644 --- a/orbit/pkg/packaging/windows_templates.go +++ b/orbit/pkg/packaging/windows_templates.go @@ -52,7 +52,7 @@ var windowsWixTemplate = template.Must(template.New("").Option("missingkey=error ErrorControl="ignore" Start="auto" Type="ownProcess" - Arguments='--root-dir "[ORBITROOT]." --log-file "[ORBITROOT]orbit-log.txt" {{ if .FleetURL }}--fleet-url "{{ .FleetURL }}"{{ end }} {{ if .EnrollSecret }}--enroll-secret-path "[ORBITROOT]secret.txt"{{ end }} {{if .Insecure }}--insecure{{ end }} {{ if .UpdateURL }}--update-url "{{ .UpdateURL }}" {{ end }} --orbit-channel "{{ .OrbitChannel }}" --osqueryd-channel "{{ .OsquerydChannel }}"' + Arguments='--root-dir "[ORBITROOT]." --log-file "[ORBITROOT]orbit-log.txt" {{ if .FleetURL }}--fleet-url "{{ .FleetURL }}"{{ end }} {{ if .FleetCertificate }}--fleet-certificate "[ORBITROOT]fleet.pem"{{ end }} {{ if .EnrollSecret }}--enroll-secret-path "[ORBITROOT]secret.txt"{{ end }} {{if .Insecure }}--insecure{{ end }} {{ if .UpdateURL }}--update-url "{{ .UpdateURL }}" {{ end }} --orbit-channel "{{ .OrbitChannel }}" --osqueryd-channel "{{ .OsquerydChannel }}"' >