Skip to content

Commit ff4cfc0

Browse files
authored
Merge pull request #278 from steviecoaster/gh153
(#153) Enable FIPs if required
2 parents c446da8 + 12b2c0e commit ff4cfc0

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

OfflineInstallPreparation.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ $ErrorActionPreference = "Stop"
6060
$ProgressPreference = "SilentlyContinue"
6161
$LicensePath = Convert-Path $LicensePath
6262

63-
Import-Module $PSScriptRoot\modules\C4B-Environment
64-
6563
$ChocoInstallScript = Join-Path $PSScriptRoot "scripts\ChocolateyInstall.ps1"
6664
if (-not (Test-Path $ChocoInstallScript)) {
6765
Invoke-WebRequest -Uri 'https://chocolatey.org/install.ps1' -OutFile $ChocoInstallScript
@@ -80,6 +78,8 @@ if ($Signature.Status -eq 'Valid' -and $Signature.SignerCertificate.Subject -eq
8078
Write-Error "ChocolateyInstall.ps1 script signature is not valid. Please investigate." -ErrorAction Stop
8179
}
8280

81+
Import-Module $PSScriptRoot\modules\C4B-Environment -Force
82+
8383
# Initialize environment, ensure Chocolatey For Business, etc.
8484
$Licensed = ($($(choco.exe)[0] -match "^Chocolatey (?<Version>\S+)\s*(?<LicenseType>Business)?$") -and $Matches.LicenseType)
8585
$InstalledLicensePath = "$env:ChocolateyInstall\license\chocolatey.license.xml"

files/chocolatey.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{ "name": "KB3035131", "internalize": false },
2525
{ "name": "microsoft-edge" },
2626
{ "name": "nexus-repository" },
27-
{ "name": "pester" },
27+
{ "name": "pester", "internalize": false },
2828
{ "name": "sql-server-express" },
2929
{ "name": "temurin21jre" },
3030
{ "name": "vcredist140" }

modules/C4B-Environment/C4B-Environment.psm1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,4 +2319,14 @@ function Install-ChocolateyAgent {
23192319
}
23202320
#endregion
23212321

2322+
# Check for and configure FIPS enforcement, if required.
2323+
if (
2324+
(Get-ItemPropertyValue -Path "HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy" -Name Enabled) -eq 1 -and
2325+
$env:ChocolateyInstall -and
2326+
-not [bool]::Parse(([xml](Get-Content $env:ChocolateyInstall\config\chocolatey.config)).chocolatey.features.feature.Where{$_.Name -eq 'useFipsCompliantChecksums'}.Enabled)
2327+
) {
2328+
Write-Warning -Message "FIPS is enabled on this system. Ensuring Chocolatey uses FIPS compliant checksums"
2329+
Invoke-Choco feature enable --name='useFipsCompliantChecksums'
2330+
}
2331+
23222332
Export-ModuleMember -Function "*"

scripts/ClientSetup.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ $script = $webClient.DownloadString("https://${hostAddress}/repository/choco-ins
105105
# Run the Chocolatey Install script with the parameters provided
106106
& ([scriptblock]::Create($script)) @params
107107

108+
# If FIPS is enabled, configure Chocolatey to use FIPS compliant checksums
109+
$fipsStatus = Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy" -Name Enabled
110+
if ($fipsStatus.Enabled -eq 1) {
111+
Write-Warning -Message "FIPS is enabled on this system. Ensuring Chocolatey uses FIPS compliant checksums"
112+
choco feature enable --name='useFipsCompliantChecksums'
113+
}
114+
108115
choco config set cacheLocation $env:ChocolateyInstall\choco-cache
109116
choco config set commandExecutionTimeoutSeconds 14400
110117

0 commit comments

Comments
 (0)