Skip to content

Commit b30ece5

Browse files
authored
eng: Remove PFXs from codebase (#2219)
* Squashed commit of the following: commit a7d4033 Author: Tian Liao <[email protected]> Date: Mon Aug 12 16:58:30 2024 +0800 remove pfx from ignore list commit 26ffa46 Author: Tian Liao <[email protected]> Date: Mon Aug 12 16:58:07 2024 +0800 Remove PFXs * fix yaml * fix gh action * fix gh action
1 parent 3782412 commit b30ece5

File tree

11 files changed

+59
-50
lines changed

11 files changed

+59
-50
lines changed

.config/CredScanSuppressions.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/action-ci.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ jobs:
9191
with:
9292
name: Build-${{ matrix.platform }}
9393
path: ${{ github.workspace }}/output
94+
- uses: actions/upload-artifact@v4
95+
with:
96+
name: Tools-${{ matrix.platform }}
97+
path: ${{ github.workspace }}/build/scripts/SignTestApp.ps1
9498

9599
unitTests:
96100
needs: [defineBuilds, build]
@@ -107,10 +111,13 @@ jobs:
107111
with:
108112
name: Build-${{ matrix.platform }}
109113
path: ${{ github.workspace }}/download
114+
- uses: actions/download-artifact@v4
115+
name: Download tools
116+
with:
117+
name: Tools-${{ matrix.platform }}
118+
path: ${{ github.workspace }}/download/tools
110119
- run: |
111-
${{ env.testDir }}/Add-AppDevPackage.ps1 `
112-
-CertificatePath ${{ env.testDir }}/CalculatorUnitTests.cer `
113-
-Force
120+
${{ github.workspace }}/download/tools/SignTestApp.ps1 -AppToSign ${{ env.testDir }}/CalculatorUnitTests.msix
114121
shell: pwsh
115122
name: Install test certificate
116123
- uses: ilammy/msvc-dev-cmd@v1 # this is a workaround because microsoft/vstest-action is broken.
@@ -131,16 +138,18 @@ jobs:
131138
with:
132139
name: Build-x64
133140
path: ${{ github.workspace }}/download
141+
- uses: actions/download-artifact@v4
142+
name: Download tools
143+
with:
144+
name: Tools-x64
145+
path: ${{ github.workspace }}/download/tools
134146
- run: |
135147
Set-DisplayResolution -Width 1920 -Height 1080 -Force
136148
shell: pwsh
137149
name: Set screen resolution
138150
- run: |
139-
${{ env.appDir }}/Add-AppDevPackage.ps1 `
140-
-CertificatePath ${{ env.appDir }}/Calculator*.cer `
141-
-Force
142-
${{ env.appDir }}/Add-AppDevPackage.ps1 `
143-
-Force
151+
${{ github.workspace }}/download/tools/SignTestApp.ps1 -AppToSign '${{ env.appDir }}/Calculator_*.msixbundle'
152+
${{ env.appDir }}/Add-AppDevPackage.ps1 -Force
144153
shell: powershell
145154
name: Install app
146155
- run: |

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ ClientBin/
200200
*.dbmdl
201201
*.dbproj.schemaview
202202
*.jfm
203-
*.pfx
204203
*.publishsettings
205204
orleans.codegen.cs
206205

@@ -294,8 +293,6 @@ __pycache__/
294293
Generated Files/
295294
src/GraphControl/GraphingImplOverrides.props
296295
src/CalcViewModel/DataLoaders/DataLoaderConstants.h
297-
!src/Calculator/WindowsDev_TemporaryKey.pfx
298-
!src/CalculatorUnitTests/WindowsDev_TemporaryKey.pfx
299296
!src/x64
300297
!src/x86
301298
!src/out

build/pipelines/templates/run-ui-tests.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,10 @@ jobs:
4242
Calculator/AppPackages/**
4343
publish/**
4444
45-
- task: PowerShell@2
46-
displayName: Install certificate
47-
inputs:
48-
filePath: $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Add-AppDevPackage.ps1
49-
arguments: -CertificatePath $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Calculator_$(Build.BuildNumber)_${{ parameters.platform }}.cer -Force
50-
51-
- task: PowerShell@2
45+
- powershell: |
46+
$(Build.SourcesDirectory)/build/scripts/SignTestApp.ps1 -AppToSign '$(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_*_Test/Calculator_*.msixbundle'
47+
$(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_*_Test/Add-AppDevPackage.ps1 -Force
5248
displayName: Install app
53-
inputs:
54-
filePath: $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Add-AppDevPackage.ps1
55-
arguments: -Force
5649
5750
- task: VSTest@2
5851
displayName: Run CalculatorUITests

build/pipelines/templates/run-unit-tests.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ jobs:
1313
skipComponentGovernanceDetection: true
1414
UnitTestsDir: $(Pipeline.Workspace)\drop-${{ parameters.platform }}\CalculatorUnitTests\AppPackages\CalculatorUnitTests_Test
1515
steps:
16-
- checkout: none
16+
- checkout: self
17+
fetchDepth: 1
1718

1819
- download: current
1920
displayName: Download CalculatorUnitTests
2021
artifact: drop-${{ parameters.platform }}
2122
patterns: '**/CalculatorUnitTests_Test/**'
2223

23-
- task: PowerShell@2
24-
displayName: Install Certificate
25-
inputs:
26-
filePath: $(UnitTestsDir)\Add-AppDevPackage.ps1
27-
arguments: -CertificatePath $(UnitTestsDir)\CalculatorUnitTests.cer -Force
24+
- powershell: |
25+
$(Build.SourcesDirectory)/build/scripts/SignTestApp.ps1 -AppToSign '$(UnitTestsDir)\CalculatorUnitTests.msix'
26+
displayName: Sign unit tests
2827
2928
- task: VSTest@2
3029
displayName: Run CalculatorUnitTests

build/scripts/SignTestApp.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#requires -RunAsAdministrator
2+
param(
3+
[Parameter(Position = 0, Mandatory = $true)][string]$AppToSign,
4+
[string]$SignTool = "C:\Program Files (x86)\Windows Kits\10\bin\10.*\x64\signtool.exe"
5+
)
6+
7+
$AppToSign = (Resolve-Path -Path $AppToSign)[-1]
8+
Write-Host "AppToSign: $AppToSign"
9+
$SignTool = (Resolve-Path -Path $SignTool)[-1]
10+
Write-Host "SignTool: $SignTool"
11+
if ((Test-Path -Path $SignTool -PathType Leaf) -ne $true) {
12+
Write-Error "signtool is not found with the given argument: $SignTool" -ErrorAction Stop
13+
}
14+
15+
$codeSignOid = New-Object -TypeName "System.Security.Cryptography.Oid" -ArgumentList @("1.3.6.1.5.5.7.3.3")
16+
$oidColl = New-Object -TypeName "System.Security.Cryptography.OidCollection"
17+
$oidColl.Add($codeSignOid) > $null
18+
$publisher = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
19+
$certReq = New-Object -TypeName "System.Security.Cryptography.X509Certificates.CertificateRequest" `
20+
-ArgumentList @($publisher, ([System.Security.Cryptography.ECDsa]::Create()), "SHA256")
21+
$certReq.CertificateExtensions.Add((New-Object -TypeName "System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension" `
22+
-ArgumentList @($oidColl, $false)))
23+
$now = Get-Date
24+
$cert = $certReq.CreateSelfSigned($now, $now.AddHours(1))
25+
26+
$pfxFile = "$($env:TEMP)\$(New-Guid).pfx"
27+
[System.IO.File]::WriteAllBytes($pfxFile, $cert.Export("Pfx"))
28+
Write-Host "Exported PFX: $pfxFile"
29+
30+
& $SignTool sign /fd SHA256 /a /f $pfxFile $AppToSign
31+
Write-Host "Certificate Thumbprint: $($cert.Thumbprint.ToLower())"
32+
33+
Import-PfxCertificate -CertStoreLocation 'Cert:\LocalMachine\TrustedPeople' -FilePath $pfxFile > $null

src/Calculator/Calculator.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
<FileAlignment>512</FileAlignment>
2525
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
2626
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
27-
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
28-
<PackageCertificateKeyFile>WindowsDev_TemporaryKey.pfx</PackageCertificateKeyFile>
27+
<AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
2928
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
3029
<AppxBundle>Always</AppxBundle>
3130
<GenerateProjectSpecificOutputFolder>true</GenerateProjectSpecificOutputFolder>
@@ -817,7 +816,6 @@
817816
</ItemGroup>
818817
<ItemGroup>
819818
<Content Include="Assets\CalculatorIcons.ttf" />
820-
<None Include="WindowsDev_TemporaryKey.pfx" />
821819
</ItemGroup>
822820
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
823821
<VisualStudioVersion>14.0</VisualStudioVersion>
-2.54 KB
Binary file not shown.

src/CalculatorUnitTests/CalculatorUnitTests.vcxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<!-- We want to automatic replace of MinVersion/MaxVersionTested for unit tests. -->
1717
<AppxOSMinVersionReplaceManifestVersion>true</AppxOSMinVersionReplaceManifestVersion>
1818
<AppxOSMaxVersionTestedReplaceManifestVersion>true</AppxOSMaxVersionTestedReplaceManifestVersion>
19-
<PackageCertificateKeyFile>WindowsDev_TemporaryKey.pfx</PackageCertificateKeyFile>
2019
</PropertyGroup>
2120
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2221
<ItemGroup Label="ProjectConfigurations">
@@ -289,9 +288,6 @@
289288
<Project>{cc9b4fa7-d746-4f52-9401-0ad1b4d6b16d}</Project>
290289
</ProjectReference>
291290
</ItemGroup>
292-
<ItemGroup>
293-
<None Include="WindowsDev_TemporaryKey.pfx" />
294-
</ItemGroup>
295291
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
296292
<ImportGroup Label="ExtensionTargets">
297293
</ImportGroup>

src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,4 @@
7979
<UniqueIdentifier>{d3ec8922-022d-4531-8744-f65a872f3841}</UniqueIdentifier>
8080
</Filter>
8181
</ItemGroup>
82-
<ItemGroup>
83-
<None Include="WindowsDev_TemporaryKey.pfx" />
84-
</ItemGroup>
8582
</Project>
Binary file not shown.

0 commit comments

Comments
 (0)