Add MDM CertificateList command for host certificates feature (#26479)

This commit is contained in:
Sarah Gillespie
2025-02-20 16:49:41 -06:00
committed by GitHub
parent 351f40230a
commit adf09f099d
8 changed files with 212 additions and 50 deletions
+23
View File
@@ -22,6 +22,7 @@ import (
"time"
"github.com/fleetdm/fleet/v4/pkg/fleethttp"
"github.com/fleetdm/fleet/v4/server/datastore/mysql"
"github.com/fleetdm/fleet/v4/server/fleet"
apple_mdm "github.com/fleetdm/fleet/v4/server/mdm/apple"
"github.com/fleetdm/fleet/v4/server/mdm/nanomdm/mdm"
@@ -739,6 +740,28 @@ func (c *TestAppleMDMClient) AcknowledgeInstalledApplicationList(udid, cmdUUID s
return c.sendAndDecodeCommandResponse(payload)
}
func (c *TestAppleMDMClient) AcknowledgeCertificateList(udid, cmdUUID string, certTemplates []*x509.Certificate) (*mdm.Command, error) {
var certList []fleet.MDMAppleCertificateListItem
for _, cert := range certTemplates {
b, _, err := mysql.GenerateTestCertBytes(cert)
if err != nil {
return nil, err
}
certList = append(certList, fleet.MDMAppleCertificateListItem{
CommonName: cert.Subject.CommonName,
Data: b,
})
}
cmd := map[string]any{
"CommandUUID": cmdUUID,
"UDID": udid,
"Status": "Acknowledged",
"CertificateList": certList,
}
return c.sendAndDecodeCommandResponse(cmd)
}
func (c *TestAppleMDMClient) GetBootstrapToken() ([]byte, error) {
payload := map[string]any{
"MessageType": "GetBootstrapToken",