Skip to content

Commit e64a2b1

Browse files
committed
Fixes Icinga for Windows certificate handling for all Windows environments
1 parent 356f453 commit e64a2b1

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

doc/100-General/10-Changelog.md

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1111

1212
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/32)
1313

14+
## 1.12.2 (2024-04-10)
15+
16+
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/34)
17+
18+
### Bugfixes
19+
20+
* [#719](https://github.com/Icinga/icinga-powershell-framework/pull/719) Fixes certificate handling for renewing certificates with the scheduled task background, which could fail on some Windows Server 2022 environments
21+
1422
## 1.12.1 (2024-04-09)
1523

1624
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/33)

lib/core/framework/Invoke-IcingaForWindowsMigration.psm1

+15
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,19 @@ function Invoke-IcingaForWindowsMigration()
113113

114114
Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.12.1');
115115
}
116+
117+
if (Test-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.12.2')) {
118+
Write-IcingaConsoleNotice 'Applying pending migrations required for Icinga for Windows v1.12.2';
119+
120+
# Revokes certificate handling to run as local Administrators group with highest privileges instead of LocalSystem
121+
Register-IcingaWindowsScheduledTaskRenewCertificate -Force;
122+
Start-Sleep -Seconds 1;
123+
# Enforce the certificate creation to update broken certificates
124+
Start-IcingaWindowsScheduledTaskRenewCertificate;
125+
# Restart the Icinga for Windows service
126+
Start-Sleep -Seconds 2;
127+
Restart-IcingaForWindows;
128+
129+
Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.12.2');
130+
}
116131
}

lib/core/wintasks/daemon/Register-TaskRenewCertificate.psm1

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ function Register-IcingaWindowsScheduledTaskRenewCertificate()
1717
$ScriptPath = Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\jobs\RenewCertificate.ps1';
1818
$TaskTrigger = New-ScheduledTaskTrigger -Daily -DaysInterval 1 -At '1am';
1919
$TaskAction = New-ScheduledTaskAction -Execute 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -Argument ([string]::Format("-WindowStyle Hidden -Command &{{ & '{0}' }}", $ScriptPath));
20+
$TaskPrincipal = New-ScheduledTaskPrincipal -GroupId 'S-1-5-32-544' -RunLevel 'Highest';
2021
$TaskSettings = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries -StartWhenAvailable;
2122

22-
# Set our user to execute the renewal script to LocalSystem, ensuring we have enough privilliges to create the certificate file and be able to use WinRM/SSH for service registering
23-
Register-ScheduledTask -User 'System' -TaskName $TaskName -TaskPath $TaskPath -Force -Action $TaskAction -Trigger $TaskTrigger -Settings $TaskSettings | Out-Null;
23+
Register-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -Force -Principal $TaskPrincipal -Action $TaskAction -Trigger $TaskTrigger -Settings $TaskSettings | Out-Null;
2424

2525
Write-IcingaConsoleNotice -Message 'The task "{0}" has been successfully registered at location "{1}".' -Objects $TaskName, $TaskPath;
2626
}

0 commit comments

Comments
 (0)