fix(build): 默认复用自签名证书签署 Windows 发布包
- fix(signing): 独立校验文件摘要、CMS 签名与 RFC 3161 时间戳,不修改系统信任库 - build(windows): 发布脚本和 CI 复用本机签名身份,交付公钥证书与真实信任状态
This commit is contained in:
14 files changed
+323
-39
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#requires -Version 7.4
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Path,
|
||||
[Parameter(Mandatory)][string]$CertificateThumbprint,
|
||||
[switch]$SelfSigned
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
$signature = Get-AuthenticodeSignature -LiteralPath $Path
|
||||
if ($signature.Status -eq 'NotSigned') { throw "The file has no embedded signature: $Path" }
|
||||
if (-not ('RmicWindowsSignature' -as [type])) {
|
||||
$references = @((Get-ChildItem -LiteralPath (Join-Path $PSHOME 'ref') -Filter '*.dll').FullName) +
|
||||
@([System.Security.Cryptography.Pkcs.SignedCms].Assembly.Location)
|
||||
Add-Type -Path (Join-Path $PSScriptRoot 'windows-signature.cs') -ReferencedAssemblies $references
|
||||
}
|
||||
$timestamp = [RmicWindowsSignature]::Verify([IO.Path]::GetFullPath($Path), $CertificateThumbprint, [bool]$SelfSigned)
|
||||
if (-not $SelfSigned -and $signature.Status -ne 'Valid') { throw "Windows does not trust the CA-signed output: $Path" }
|
||||
[pscustomobject]@{ file = [IO.Path]::GetFileName($Path); status = [string]$signature.Status;
|
||||
verificationStatus = $(if ($SelfSigned) { 'valid-pinned-self-signed' } else { 'valid-trusted-signature' });
|
||||
windowsTrustMessage = $signature.StatusMessage;
|
||||
integrityVerified = $true; timestamped = $true; timestampVerified = $true; timestampUtc = $timestamp.ToString('o');
|
||||
certificateThumbprint = $CertificateThumbprint; selfSigned = [bool]$SelfSigned; windowsTrusted = $signature.Status -eq 'Valid' }
|
||||
Reference in new issue
Block a user