Skip to content

Commit 5b12325

Browse files
authored
Add warning when AuthenticodeCheck is used on non-Windows platforms (#1891)
1 parent 71b35b0 commit 5b12325

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/code/Utils.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,7 @@ internal static bool CheckAuthenticodeSignature(
21602160
// Because authenticode and catalog verifications are only applicable on Windows, we allow all packages by default to be installed on unix systems.
21612161
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
21622162
{
2163+
cmdletPassedIn.WriteWarning("Authenticode check cannot be performed on Linux or MacOS.");
21632164
return true;
21642165
}
21652166

test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,14 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' {
554554
$err[0].FullyQualifiedErrorId | Should -BeExactly "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource"
555555
}
556556

557+
# Test that AuthenticodeCheck parameter displays warning on non-Windows
558+
It "Install with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) {
559+
Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -AuthenticodeCheck -WarningVariable warn -WarningAction SilentlyContinue
560+
$warn[0] | Should -Contain "Authenticode check cannot be performed on Linux or MacOS"
561+
$res = Get-InstalledPSResource $testModuleName
562+
$res.Name | Should -Be $testModuleName
563+
}
564+
557565
# Unix test for installing scripts
558566
It "Install script resource - Unix only" -Skip:(Get-IsWindows) {
559567
# previously installing pester on Unix was throwing an error due to how the environment PATH variable was being gotten.

0 commit comments

Comments
 (0)