Skip to content

Commit 5fa8cb2

Browse files
Add automatic AuthRoot cache for portable trust (#24)
## Summary - Add automatic Microsoft AuthRoot CAB caching for portable trust verification when no explicit anchors are supplied, with a 7-day stale refresh window and environment overrides. - Route supported `--mode portable verify` calls through portable trust verification by default when auto trust is enabled, and align the PowerShell module cache behavior. - Normalize exact duplicate certificates in Authenticode `SignedData.certificates` bags so Windows-valid Azure Artifact Signing signatures parse in the strict Rust CMS stack. ## Validation - `cargo build --locked` - `cargo clippy --workspace --all-targets --locked` - `cargo test -p psign-sip-digest pkcs7_wire --locked` - `cargo test -p psign-authenticode-trust --lib --locked` - `cargo test -p psign-authenticode-trust authroot_cache --locked` - `dotnet build dotnet/Devolutions.Psign.PowerShell/Devolutions.Psign.PowerShell.csproj` - `bash scripts/linux-portable-validation.sh` - `psign-tool --mode portable verify tursodb.exe` with a fresh AuthRoot cache Known baseline: full `cargo test --workspace --locked` still fails on the existing `tests/fixtures/msix-minimal/AppxManifest.xml` fixture manifest-size mismatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0eddd27 commit 5fa8cb2

21 files changed

Lines changed: 881 additions & 69 deletions

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PowerShell/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ New-PSDrive -Name certs -PSProvider PortableCertStore -Root ./project-certs
9595

9696
## Trust Model
9797

98-
By default, `Get-PsignSignature` automatically downloads and caches the Microsoft AuthRoot CAB (~350KB) for trust evaluation. The cache lives at `~/.psign/authroot/`.
98+
By default, `Get-PsignSignature`, `Test-PsignFileCatalog`, and `Test-PsignModule` automatically download and cache the Microsoft AuthRoot CAB for trust evaluation when no explicit trust anchors are supplied. The cache lives at `~/.psign/authroot/` and is refreshed when it is older than 7 days. Set `PSIGN_AUTHROOT_MAX_AGE_DAYS`, `PSIGN_AUTHROOT_CACHE_DIR`, or `PSIGN_AUTHROOT_URL` to override the stale window, cache directory, or source URL.
9999

100100
```powershell
101101
# Disable auto-trust

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ cargo build -p psign --bin psign-tool --locked
8686
# Portable PE signing with a local RSA key:
8787
# psign-tool portable sign-pe --cert cert.der --key key.pk8 --output signed.exe unsigned.exe
8888
# Existing PE signatures are replaced by default; add --append-signature to match signtool /as.
89-
# Portable trust verification with explicit anchors:
89+
# Portable trust verification downloads/caches Microsoft AuthRoot automatically when no anchors are supplied:
90+
# psign-tool portable trust-verify-pe signed.exe
91+
# Explicit anchors still override auto trust:
9092
# psign-tool portable trust-verify-pe signed.exe --anchor-dir anchors
9193
# Portable custom ZIP Authenticode verification:
9294
# psign-tool portable trust-verify-zip archive.zip --anchor-dir anchors

crates/psign-authenticode-trust/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repository.workspace = true
1010
anyhow = "1"
1111
base64 = "0.22"
1212
serde = { version = "1", features = ["derive"] }
13+
serde_json = "1"
1314
cms = "0.2.3"
1415
der = { version = "0.7", features = ["derive"] }
1516
digest = "0.10"
@@ -20,7 +21,7 @@ authenticode = { version = "0.5.0", features = ["std", "object"] }
2021
psign-sip-digest = { path = "../psign-sip-digest" }
2122
picky = { version = "7.0.0-rc.23", features = ["pkcs7", "time_conversion"] }
2223
picky-asn1-x509 = "0.15.4"
23-
time = "0.3"
24+
time = { version = "0.3", features = ["formatting", "parsing"] }
2425
x509-cert = "0.2.5"
2526
cab = "0.6"
2627

0 commit comments

Comments
 (0)