From 5aa0a9f13bed1c32cd1c8841cfa40ff6560af0a5 Mon Sep 17 00:00:00 2001 From: Timotheus Bachinger Date: Wed, 30 Sep 2026 09:48:20 +0200 Subject: [PATCH] Forward Artifact Signing correlation ID for PowerShell scripts ## Summary - Pass `--artifact-signing-correlation-id` (or the metadata `CorrelationId`) through the portable-core Artifact Signing provider, so the `:sign` request carries `x-correlation-id` / `x-ms-correlation-id` for PowerShell scripts (and MSIX/AppX) as it already does for PE, CAB and MSI. - Stop rejecting the correlation ID in native-shaped portable signing; signature-algorithm, api-version and authority overrides are still rejected there. Callers use the correlation ID to attribute signing requests in the Artifact Signing diagnostics. Previously, signing a `.ps1` with it set failed with "does not yet support correlation ID". ## Verification - New test `mode_portable_artifact_signing_forwards_correlation_id_for_scripts`: `psign-server --expect-correlation-id` rejects the request without the header; fails before the change, passes after. - `bash scripts/linux-portable-validation.sh` - Signed a PE, an MSI and a `.ps1` against a real Artifact Signing account from Linux: `Get-AuthenticodeSignature` reports `Valid` on Windows, and the service diagnostics show the correlation ID on all requests. --- crates/psign-portable-core/src/lib.rs | 8 ++++- src/portable_sign.rs | 6 ++-- tests/cli_pe_digest.rs | 42 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/crates/psign-portable-core/src/lib.rs b/crates/psign-portable-core/src/lib.rs index 85ab31f..50ef2eb 100644 --- a/crates/psign-portable-core/src/lib.rs +++ b/crates/psign-portable-core/src/lib.rs @@ -351,6 +351,8 @@ pub struct PortableSignRequest { pub artifact_signing_federated_token_file: Option, #[serde(default)] pub artifact_signing_exclude_credentials: Vec, + #[serde(default)] + pub artifact_signing_correlation_id: Option, } impl Default for PortableSignRequest { @@ -392,6 +394,7 @@ impl Default for PortableSignRequest { artifact_signing_client_secret: None, artifact_signing_federated_token_file: None, artifact_signing_exclude_credentials: Vec::new(), + artifact_signing_correlation_id: None, } } } @@ -1195,6 +1198,7 @@ struct ArtifactSigningProvider { endpoint: String, account_name: String, profile_name: String, + correlation_id: Option, auth: psign_codesigning_rest::CodesigningAuth, chain: Vec, } @@ -1391,7 +1395,7 @@ impl SigningProvider { digest: digest.to_vec(), signature_algorithm: artifact_signature_algorithm(digest_algorithm).to_string(), api_version: psign_codesigning_rest::DEFAULT_API_VERSION.to_string(), - correlation_id: None, + correlation_id: provider.correlation_id.clone(), authority: None, auth: provider.auth.clone(), endpoint_base_url: Some(provider.endpoint.clone()), @@ -1509,6 +1513,7 @@ fn load_artifact_signing_provider(request: &PortableSignRequest) -> Result