Fix decoding enrollment profiles (#20984)
This commit is contained in:
@@ -3463,9 +3463,13 @@ func RenewSCEPCertificates(
|
||||
}
|
||||
}
|
||||
|
||||
migrationEnrollmentProfile := os.Getenv("FLEET_SILENT_MIGRATION_ENROLLMENT_PROFILE")
|
||||
decodedMigrationEnrollmentProfile, err := base64.StdEncoding.DecodeString(os.Getenv("FLEET_SILENT_MIGRATION_ENROLLMENT_PROFILE"))
|
||||
if err != nil {
|
||||
return ctxerr.Wrap(ctx, err, "failed to decode silent migration enrollment profile")
|
||||
}
|
||||
hasAssocsFromMigration := len(assocsFromMigration) > 0
|
||||
|
||||
migrationEnrollmentProfile := string(decodedMigrationEnrollmentProfile)
|
||||
if migrationEnrollmentProfile == "" && hasAssocsFromMigration {
|
||||
level.Debug(logger).Log("msg", "found devices from migration that need SCEP renewals but FLEET_SILENT_MIGRATION_ENROLLMENT_PROFILE is empty")
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
@@ -772,7 +773,7 @@ func (s *integrationMDMTestSuite) TestLifecycleSCEPCertExpiration() {
|
||||
require.NoError(t, err)
|
||||
|
||||
// set the env var, and run the cron
|
||||
t.Setenv("FLEET_SILENT_MIGRATION_ENROLLMENT_PROFILE", "<foo></foo>")
|
||||
t.Setenv("FLEET_SILENT_MIGRATION_ENROLLMENT_PROFILE", base64.StdEncoding.EncodeToString([]byte("<foo></foo>")))
|
||||
err = RenewSCEPCertificates(ctx, logger, s.ds, &fleetCfg, s.mdmCommander)
|
||||
require.NoError(t, err)
|
||||
checkRenewCertCommand(migratedDevice, "", "<foo></foo>")
|
||||
|
||||
Reference in New Issue
Block a user