Add opt-in SignPath signing for Windows builds

This commit is contained in:
supermerill 2026-11-12 17:55:51 +01:00
parent 13aa0fc8e3
commit b7deff655f
15 changed files with 747 additions and 8 deletions

40
.github/signpath/Prepare-Binaries.ps1 vendored Normal file
View file

@ -0,0 +1,40 @@
param(
[Parameter(Mandatory = $true)][string]$SourceDirectory,
[Parameter(Mandatory = $true)][string]$OutputDirectory
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
# The XML is also the CI allowlist, so a broad *.dll copy cannot sign upstream DLLs.
[xml]$configuration = Get-Content -LiteralPath "$PSScriptRoot/artifact-configuration-binaries.xml"
$namespaces = New-Object System.Xml.XmlNamespaceManager($configuration.NameTable)
$namespaces.AddNamespace('s', 'http://signpath.io/artifact-configuration/v1')
$fileSet = $configuration.SelectSingleNode('/s:artifact-configuration/s:zip-file/s:pe-file-set', $namespaces)
$version = $null
$files = foreach ($include in $fileSet.SelectNodes('s:include', $namespaces)) {
$name = $include.GetAttribute('path')
if ($name -notmatch '^[a-zA-Z0-9_.-]+\.(exe|dll)$') {
throw "Expected a literal binary filename in the signing allowlist: $name"
}
$file = Get-Item -LiteralPath (Join-Path $SourceDirectory $name)
if ($file.VersionInfo.ProductName -cne $fileSet.GetAttribute('product-name')) {
throw "Unexpected ProductName on $name"
}
$productVersion = $file.VersionInfo.ProductVersion
if ([string]::IsNullOrWhiteSpace($productVersion)) { throw "Missing ProductVersion on $name" }
if ($null -ne $version -and $productVersion -cne $version) {
throw "ProductVersion mismatch on $name"
}
$version = $productVersion
$file
}
if (@($files).Count -ne 5) { throw 'Expected exactly five SuperSlicer binaries' }
# Fail if the directory already exists rather than accidentally reusing stale inputs.
New-Item -ItemType Directory -Path $OutputDirectory | Out-Null
$files | Copy-Item -Destination $OutputDirectory
Write-Host "Signing five SuperSlicer binaries with ProductVersion $version"
if ($env:GITHUB_OUTPUT) {
"product-version=$version" | Out-File -LiteralPath $env:GITHUB_OUTPUT -Encoding utf8 -Append
}

139
.github/signpath/README.md vendored Normal file
View file

@ -0,0 +1,139 @@
# Windows code signing (SignPath)
The integration is in `.github/workflows/ccpp_win.yml` (Windows **nightly** only).
`ccpp_win_rc.yml` and `ccpp_win_debug.yml` are not integrated yet. Signing is **off by
default**: existing unsigned builds continue until explicitly enabled in GitHub.
## GitHub settings
In the repository, open **Settings → Secrets and variables → Actions**.
Add the following repository **variables** (not secrets):
| Variable | Value |
| --- | --- |
| `SIGNPATH_ENABLED` | `true` only when all settings below are ready; unset or `false` disables signing |
| `SIGNPATH_ORGANIZATION_ID` | UUID of the organization actually containing the project and certificate |
| `SIGNPATH_PROJECT_SLUG` | `superslicer` by default; override if the existing project has another slug |
| `SIGNPATH_SIGNING_POLICY_SLUG` | the actual policy slug; use a test policy first, e.g. `test-signing` |
| `SIGNPATH_TEST_CERTIFICATE_THUMBPRINT` | **test only**: SHA-1 thumbprint (40 hex characters) of the self-signed certificate, copied from SignPath or its exported public certificate |
Add `SIGNPATH_API_TOKEN` as a repository **secret**. Do not put it in these files.
Its user must have **submitter** permission on the selected signing policy. Missing
required settings fail early when signing is enabled; signing failures never silently
fall back to publishing unsigned binaries.
## Objects to create in SignPath
In the selected organization, create or check these objects. Slugs must match CI exactly.
| Object | Slug used by CI | Notes |
| --- | --- | --- |
| Organization | — | its UUID goes in the `SIGNPATH_ORGANIZATION_ID` GitHub variable |
| Trusted Build System | — | add *GitHub.com*, then link it to the project. SignPath then checks that the artifact really comes from a GitHub workflow |
| Project | `superslicer` | Settings → connect the GitHub repository |
| Signing Policy | e.g. `test-signing` | assign the test certificate, authorize the submitter and configure manual approval by the maintainer; put the slug in `SIGNPATH_SIGNING_POLICY_SLUG` |
| Artifact Configuration | `windows-binaries` | content of `artifact-configuration-binaries.xml` |
| Artifact Configuration | `windows-msi` | content of `artifact-configuration-msi.xml` |
| API token | — | user profile → API tokens, stored as the `SIGNPATH_API_TOKEN` GitHub secret |
Use MFA for both GitHub and SignPath accounts. Restrict the project's allowed source
repository/branches to the intended SuperSlicer builds. When requested by SignPath's
integration or policy checks, install the [SignPath GitHub App](https://github.com/apps/signpath)
with access limited to this repository.
Artifact configurations are created with **Add → Custom** and the XML pasted in.
**Upload an artifact sample** instead only if the XML drifts from the real package:
it regenerates the file list from an actual ZIP and is the fastest way to see what
SignPath recognised.
## Certificate
A self-signed test certificate is enough to validate the pipeline, but Windows runners
do **not** trust it by default. Set `SIGNPATH_TEST_CERTIFICATE_THUMBPRINT` to pin this
exact certificate. Test verification checks the certificate's validity and code-signing
usage and calls Windows `WinVerifyTrust` to verify each signature and file digest. Only
the expected untrusted-root error is tolerated for this pinned self-signed certificate;
no certificate is installed in a trust store. It rejects missing files, unexpected
files, unsigned or tampered files and signatures made with another test certificate.
The MSI is verified too. Production uses `signtool verify /pa /all` without exceptions.
Test outputs are named `test-signed_nightly_...` and **must not be published as trusted
releases**. Self-signed test signatures do not remove Windows publisher warnings.
Only ask SignPath OSS support for the production certificate after a complete run.
If the project is invalid, read its validation details and check the policy's
certificate, permissions and artifact configuration. For an expired OSS test
certificate, ask OSS support to replace it if you cannot do so in that organization.
Update the pinned thumbprint after replacing a test certificate.
## Switching from the trial organization to the OSS organization
Keep signing disabled while switching. The old trial organization's objects and
certificate do not automatically move to the OSS organization:
1. Accept the invitation and select the **OSS** organization.
2. Check/create the project, GitHub trusted build system link, signing policy,
submitter/approver permissions and both artifact configurations there.
3. Change `SIGNPATH_ORGANIZATION_ID`, policy/project slugs if different, the
`SIGNPATH_API_TOKEN` secret and the test certificate thumbprint in GitHub.
4. Enable signing and complete an end-to-end test in the OSS organization.
Once SignPath has reviewed the setup and imported a **production** certificate, assign
it to a manually approved release policy, select that policy in GitHub, and **remove
`SIGNPATH_TEST_CERTIFICATE_THUMBPRINT`**. Production verification then uses the normal
Windows trust chain, with no private certificate imported.
## Why the artifact is not the whole package
`build/package/` contains `VCRUNTIME140*`, `msvcp140*` and the mesa DLLs, which are not
ours to sign. Moreover, `src/RelWithDebInfo/` also contains copied `libgmp-10.dll` and
`libmpfr-4.dll`, so **copying `*.dll` from there is unsafe too**.
`Prepare-Binaries.ps1` uses the XML's explicit five-file allowlist, validates their
`ProductName` and common `ProductVersion`, and submits only those files. All five
carry VERSIONINFO resources (including the two DLLs); the viewer keeps its distinct
file description but uses the same product name. The actual product version is passed
as the required `version` parameter and enforced by SignPath on all five files.
The verified signed result is copied into `build/package/` before the MSI is harvested.
The MSI is signed in a second request, after `light.exe`.
## First run
`wait-for-completion: true` means CI waits for the signing request to be approved.
If the signing policy requires manual approval, open SignPath → *My Requests* and approve
while the workflow is running. If it times out, raise
`wait-for-completion-timeout-in-seconds` in the workflow.
There are **two signing requests per build**: binaries, then MSI. Both need approval
when manual approval is configured. Check trial quotas before testing: a trial plan
may not allow both requests; use the OSS organization's test certificate for integration.
The workflow runs on its listed nightly/debug branches or via `workflow_dispatch`
(GitHub's manual Run workflow button requires the workflow on the default branch).
Push these changes to the branch being built before trying the integration.
Before requesting the production review, link the [code signing policy](../../doc/Code%20signing%20policy.md)
from the actual project home/download/release pages as well, and confirm the listed
team roles and privacy statements accurately describe the project.
References: [GitHub integration](https://docs.signpath.io/trusted-build-systems/github),
[artifact configuration](https://docs.signpath.io/artifact-configuration),
[OSS requirements](https://signpath.org/terms).
## Local verification
On Windows with Visual Studio 2022, CMake, the Windows SDK and WiX v3 installed:
```powershell
./.github/signpath/tests/Test-Integration.ps1 -WorkDirectory <new-test-directory> -WixDirectory <wix-v3-bin-directory>
```
This builds tiny EXE/DLL fixtures using the actual resource templates and checks the
allowlist, metadata, certificate pinning, missing/unexpected outputs, tampering,
absence of changes to root trust and MSI verification using the actual installer template.
It also checks normal public-root verification on the Microsoft-signed SDK tool.
It creates and deletes its own temporary test certificate in the current user's
certificate store. It does not contact SignPath,
install an MSI, or replace an end-to-end CI test with the real SignPath organization.

View file

@ -0,0 +1,67 @@
param(
[Parameter(Mandatory = $true)][string]$UnsignedDirectory,
[Parameter(Mandatory = $true)][string]$SignedDirectory,
[Parameter(Mandatory = $true)][string]$DestinationDirectory,
[AllowEmptyString()][string]$TestCertificateThumbprint = ''
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$unsigned = @(Get-ChildItem -LiteralPath $UnsignedDirectory)
$signed = @(Get-ChildItem -LiteralPath $SignedDirectory)
if ($unsigned.Count -eq 0 -or @($unsigned | Where-Object PSIsContainer).Count -ne 0 -or
@($signed | Where-Object PSIsContainer).Count -ne 0) {
throw 'Expected non-empty, flat signing artifact directories'
}
if ($unsigned.Count -ne $signed.Count -or
@(Compare-Object ($unsigned.Name | Sort-Object) ($signed.Name | Sort-Object)).Count -ne 0) {
throw 'Signed artifact filenames do not exactly match the submitted files'
}
if (-not (Test-Path -LiteralPath $DestinationDirectory -PathType Container)) {
throw "Destination directory does not exist: $DestinationDirectory"
}
$signtool = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\signtool.exe" |
Sort-Object { [version]$_.Directory.Parent.Name } -Descending | Select-Object -First 1
if (-not $signtool) { throw 'signtool.exe not found' }
$thumbprint = ($TestCertificateThumbprint -replace '\s', '').ToUpperInvariant()
if ($thumbprint -and $thumbprint -notmatch '^[0-9A-F]{40}$') {
throw 'The test certificate SHA-1 thumbprint must contain exactly 40 hexadecimal characters'
}
if ($thumbprint -and -not ('SignPathTestSignature' -as [type])) {
Add-Type -Path "$PSScriptRoot/Verify-TestSignature.cs"
}
foreach ($file in $signed) {
if ($thumbprint) {
# Test signatures cannot satisfy public-root trust. Pin the exact signer,
# validate its dates and code-signing usage, and let WinVerifyTrust check
# the file's signature/digest. Accept ONLY success or CERT_E_UNTRUSTEDROOT,
# never generic UnknownError, HashMismatch or any other trust error.
$certificate = (Get-AuthenticodeSignature -LiteralPath $file.FullName).SignerCertificate
if ($null -eq $certificate -or $certificate.Thumbprint -ne $thumbprint -or
$certificate.Subject -ne $certificate.Issuer) {
throw "Wrong or missing self-signed test certificate on $($file.Name)"
}
$chain = New-Object System.Security.Cryptography.X509Certificates.X509Chain
try {
$chain.ChainPolicy.VerificationFlags = [Security.Cryptography.X509Certificates.X509VerificationFlags]::AllowUnknownCertificateAuthority
$chain.ChainPolicy.RevocationMode = [Security.Cryptography.X509Certificates.X509RevocationMode]::NoCheck
[void]$chain.ChainPolicy.ApplicationPolicy.Add((New-Object Security.Cryptography.Oid('1.3.6.1.5.5.7.3.3')))
if (-not $chain.Build($certificate)) { throw "Invalid test certificate on $($file.Name)" }
} finally { $chain.Dispose() }
$result = [SignPathTestSignature]::Verify($file.FullName)
if ($result -ne 0 -and $result -ne 2148204809) { # 0x800B0109: CERT_E_UNTRUSTEDROOT
throw ('Invalid test signature on {0}: 0x{1:X8}' -f $file.Name, $result)
}
Write-Host "Verified pinned test signature: $($file.Name)"
} else {
& $signtool.FullName verify /pa /all /v $file.FullName
if ($LASTEXITCODE -ne 0) { throw "Invalid signature: $($file.Name)" }
}
}
# No fallback to unsigned originals, and copy nothing until all signatures pass.
$signed | Copy-Item -Destination $DestinationDirectory -Force

View file

@ -0,0 +1,58 @@
using System;
using System.Runtime.InteropServices;
// WinVerifyTrust verifies the file digest and signature without showing UI or
// modifying a Windows certificate store. Only test mode uses this helper; the
// caller additionally pins and validates the self-signed code-signing certificate.
public static class SignPathTestSignature
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private class FileInfo
{
public uint Size = (uint)Marshal.SizeOf(typeof(FileInfo));
[MarshalAs(UnmanagedType.LPWStr)] public string Path;
public IntPtr Handle = IntPtr.Zero;
public IntPtr KnownSubject = IntPtr.Zero;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private class TrustData
{
public uint Size = (uint)Marshal.SizeOf(typeof(TrustData));
public IntPtr PolicyCallbackData = IntPtr.Zero;
public IntPtr SipClientData = IntPtr.Zero;
public uint UIChoice = 2; // WTD_UI_NONE
public uint RevocationChecks = 0;
public uint UnionChoice = 1; // WTD_CHOICE_FILE
public IntPtr File;
public uint StateAction = 1; // WTD_STATEACTION_VERIFY
public IntPtr StateData = IntPtr.Zero;
public IntPtr URLReference = IntPtr.Zero;
public uint ProviderFlags = 0x1010; // cache-only URL retrieval, no revocation (pinned test cert)
public uint UIContext = 0;
public IntPtr SignatureSettings = IntPtr.Zero;
}
[DllImport("wintrust.dll", ExactSpelling = true)]
private static extern int WinVerifyTrust(IntPtr window, ref Guid action, [In, Out] TrustData data);
public static uint Verify(string path)
{
var file = new FileInfo { Path = path };
var pointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FileInfo)));
var data = new TrustData { File = pointer };
var action = new Guid("00AAC56B-CD44-11d0-8CC2-00C04FC295EE"); // GENERIC_VERIFY_V2
Marshal.StructureToPtr(file, pointer, false);
try
{
return unchecked((uint)WinVerifyTrust(new IntPtr(-1), ref action, data));
}
finally
{
data.StateAction = 2; // WTD_STATEACTION_CLOSE
WinVerifyTrust(new IntPtr(-1), ref action, data);
Marshal.DestroyStructure(pointer, typeof(FileInfo));
Marshal.FreeHGlobal(pointer);
}
}
}

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SignPath artifact configuration - SuperSlicer Windows binaries.
The artifact submitted from GitHub is the ZIP produced by actions/upload-artifact,
so the root element MUST be <zip-file>. The ZIP only contains files built by this
project (build/sign-input): no third-party DLL, no mesa, no VCRUNTIME.
Paste this content into:
Project -> Artifact Configurations -> Add -> Custom
and give it the slug "windows-binaries".
All five binaries carry ProductName "SuperSlicer" and the same ProductVersion.
The workflow reads that version from the binaries and passes it as a parameter.
Keep this explicit allowlist: the build directory also contains third-party DLLs.
-->
<artifact-configuration xmlns="http://signpath.io/artifact-configuration/v1">
<parameters>
<parameter name="version" required="true" />
</parameters>
<zip-file>
<pe-file-set product-name="SuperSlicer" product-version="${version}">
<include path="superslicer.exe" />
<include path="superslicer_console.exe" />
<include path="superslicer-gcodeviewer.exe" />
<include path="Slic3r.dll" />
<include path="OCCTWrapper.dll" />
<for-each>
<authenticode-sign />
</for-each>
</pe-file-set>
</zip-file>
</artifact-configuration>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SignPath artifact configuration - SuperSlicer Windows MSI.
Same rule: the uploaded artifact is a ZIP, so the root element is <zip-file>.
Only the .msi is signed here: the executables and DLLs it contains have already
been signed in a previous request, and the third-party DLLs bundled in the package
must never be signed with our certificate.
Paste into: Project -> Artifact Configurations -> Add -> Custom
Slug: "windows-msi"
-->
<artifact-configuration xmlns="http://signpath.io/artifact-configuration/v1">
<zip-file>
<msi-file path="SuperSlicer_*.msi">
<authenticode-sign />
</msi-file>
</zip-file>
</artifact-configuration>

37
.github/signpath/tests/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.13)
project(SignPathFixtures C)
get_filename_component(REPOSITORY "${CMAKE_CURRENT_SOURCE_DIR}/../../.." ABSOLUTE)
include("${REPOSITORY}/version.inc")
set(SLIC3R_RESOURCES_DIR "${REPOSITORY}/resources")
configure_file("${REPOSITORY}/src/platform/msw/PrusaSlicer.manifest.in" "${SLIC3R_APP_KEY}.manifest" @ONLY)
configure_file("${REPOSITORY}/src/platform/msw/Slic3r.rc.in" "superslicer.rc" @ONLY)
configure_file("${REPOSITORY}/src/platform/msw/gcodeviewer.rc.in" "gcodeviewer.rc" @ONLY)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/stub.c" "int main(void) { return 0; }\n")
foreach(name superslicer superslicer_console superslicer-gcodeviewer)
if(name STREQUAL "superslicer-gcodeviewer")
set(resource "${CMAKE_CURRENT_BINARY_DIR}/gcodeviewer.rc")
else()
set(resource "${CMAKE_CURRENT_BINARY_DIR}/superslicer.rc")
endif()
add_executable(${name} "${CMAKE_CURRENT_BINARY_DIR}/stub.c" "${resource}")
target_include_directories(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
target_link_options(${name} PRIVATE /MANIFEST:NO)
endforeach()
foreach(name Slic3r OCCTWrapper)
set(SLIC3R_DLL_NAME "${name}")
configure_file("${REPOSITORY}/src/platform/msw/Dll.rc.in" "${name}.rc" @ONLY)
add_library(${name} SHARED "${CMAKE_CURRENT_BINARY_DIR}/stub.c" "${CMAKE_CURRENT_BINARY_DIR}/${name}.rc")
endforeach()
# These deliberately have no SuperSlicer metadata and must not be submitted.
foreach(name libgmp-10 libmpfr-4)
add_library(${name} SHARED "${CMAKE_CURRENT_BINARY_DIR}/stub.c")
endforeach()
# Use the real MSI template, but never the real product's upgrade code or registry key.
set(SLIC3R_GUID "3fa87a13-05cb-4fee-8e09-cdc6d131cd86")
set(SLIC3R_APP_KEY "SuperSlicerSignatureFixture")
configure_file("${REPOSITORY}/src/platform/msw/winInstaller.wxs.in" "winInstaller.wxs" @ONLY)

View file

@ -0,0 +1,153 @@
param(
[Parameter(Mandatory = $true)][string]$WorkDirectory,
[string]$WixDirectory = ''
)
# Windows-only smoke tests. Requires VS 2022, CMake, Windows SDK and WiX v3.
# Builds tiny fixtures, never SuperSlicer, installs nothing and calls no SignPath API.
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
if ($WixDirectory) {
$candle = (Get-Item -LiteralPath "$WixDirectory/candle.exe").FullName
$light = (Get-Item -LiteralPath "$WixDirectory/light.exe").FullName
$heat = (Get-Item -LiteralPath "$WixDirectory/heat.exe").FullName
} else {
$candle = (Get-Command candle.exe).Source
$light = (Get-Command light.exe).Source
$heat = (Get-Command heat.exe).Source
}
$wixUI = Join-Path (Split-Path $light -Parent) 'WixUIExtension.dll'
function Assert-Fails([scriptblock]$Action, [string]$Description) {
$failed = $false
try { & $Action } catch { $failed = $true }
if (-not $failed) { throw "Expected failure: $Description" }
Write-Host "PASS: rejects $Description"
}
function Assert-NoTemporaryTrust {
if (Test-Path "Cert:\CurrentUser\Root\$($certificate.Thumbprint)") {
throw 'Root trust was unexpectedly changed'
}
}
New-Item -ItemType Directory -Path $WorkDirectory | Out-Null
$WorkDirectory = (Resolve-Path -LiteralPath $WorkDirectory).Path
$scripts = Split-Path $PSScriptRoot -Parent
& cmake -S $PSScriptRoot -B "$WorkDirectory/build" -G 'Visual Studio 17 2022' -A x64
if ($LASTEXITCODE -ne 0) { throw 'Fixture CMake configuration failed' }
& cmake --build "$WorkDirectory/build" --config RelWithDebInfo --parallel
if ($LASTEXITCODE -ne 0) { throw 'Fixture build failed' }
$fixtures = "$WorkDirectory/build/RelWithDebInfo"
$unsigned = "$WorkDirectory/unsigned"
& "$scripts/Prepare-Binaries.ps1" -SourceDirectory $fixtures -OutputDirectory $unsigned
if (@(Get-ChildItem -LiteralPath $unsigned).Count -ne 5 -or
(Test-Path "$unsigned/libgmp-10.dll") -or (Test-Path "$unsigned/libmpfr-4.dll")) {
throw 'Third-party DLLs were not excluded'
}
Write-Host 'PASS: exactly five binaries with consistent metadata, no third-party DLLs'
$missing = "$WorkDirectory/missing"
Copy-Item -LiteralPath $unsigned -Destination $missing -Recurse
Remove-Item -LiteralPath "$missing/OCCTWrapper.dll"
Assert-Fails { & "$scripts/Prepare-Binaries.ps1" -SourceDirectory $missing -OutputDirectory "$WorkDirectory/not-created" } 'missing input binary'
Copy-Item -LiteralPath "$fixtures/libgmp-10.dll" -Destination "$missing/OCCTWrapper.dll"
Assert-Fails { & "$scripts/Prepare-Binaries.ps1" -SourceDirectory $missing -OutputDirectory "$WorkDirectory/not-created" } 'wrong input metadata'
$signtool = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\signtool.exe" |
Sort-Object { [version]$_.Directory.Parent.Name } -Descending | Select-Object -First 1
if (-not $signtool) { throw 'signtool.exe not found' }
$certificate = $null
try {
$certificate = New-SelfSignedCertificate -Subject "CN=SuperSlicer fixture $([guid]::NewGuid())" `
-Type CodeSigningCert -CertStoreLocation Cert:\CurrentUser\My -NotAfter (Get-Date).AddDays(1)
$signed = "$WorkDirectory/signed"
Copy-Item -LiteralPath $unsigned -Destination $signed -Recurse
foreach ($file in Get-ChildItem -LiteralPath $signed) {
& $signtool.FullName sign /s My /sha1 $certificate.Thumbprint /fd SHA256 $file.FullName
if ($LASTEXITCODE -ne 0) { throw "Fixture signing failed: $($file.Name)" }
}
$destination = "$WorkDirectory/package"
New-Item -ItemType Directory -Path $destination | Out-Null
$arguments = @{
UnsignedDirectory = $unsigned
SignedDirectory = $signed
DestinationDirectory = $destination
}
Assert-Fails { & "$scripts/Update-SignedArtifacts.ps1" -UnsignedDirectory $unsigned -SignedDirectory $unsigned -DestinationDirectory $destination -TestCertificateThumbprint $certificate.Thumbprint } 'unsigned output'
Assert-Fails { & "$scripts/Update-SignedArtifacts.ps1" @arguments } 'untrusted self-signed certificate without opt-in'
Assert-Fails { & "$scripts/Update-SignedArtifacts.ps1" @arguments -TestCertificateThumbprint ('0' * 40) } 'wrong certificate pin'
& "$scripts/Update-SignedArtifacts.ps1" @arguments -TestCertificateThumbprint $certificate.Thumbprint
Assert-NoTemporaryTrust
foreach ($file in Get-ChildItem -LiteralPath $signed) {
if ((Get-FileHash $file.FullName).Hash -ne (Get-FileHash "$destination/$($file.Name)").Hash) {
throw 'Signed copy differs'
}
}
Write-Host 'PASS: pinned test signatures verified and copied without changing root trust'
$incomplete = "$WorkDirectory/incomplete"
Copy-Item -LiteralPath $signed -Destination $incomplete -Recurse
Remove-Item -LiteralPath "$incomplete/Slic3r.dll"
Assert-Fails { & "$scripts/Update-SignedArtifacts.ps1" -UnsignedDirectory $unsigned -SignedDirectory $incomplete -DestinationDirectory $destination } 'missing signed output'
Copy-Item -LiteralPath "$signed/Slic3r.dll" -Destination $incomplete
Copy-Item -LiteralPath "$fixtures/libgmp-10.dll" -Destination $incomplete
Assert-Fails { & "$scripts/Update-SignedArtifacts.ps1" -UnsignedDirectory $unsigned -SignedDirectory $incomplete -DestinationDirectory $destination } 'unexpected signed output'
$tampered = "$WorkDirectory/tampered"
Copy-Item -LiteralPath $signed -Destination $tampered -Recurse
$stream = [IO.File]::OpenWrite("$tampered/Slic3r.dll")
try {
$stream.Position = 1024
$stream.WriteByte(123)
} finally { $stream.Dispose() }
$emptyDestination = "$WorkDirectory/empty-package"
New-Item -ItemType Directory -Path $emptyDestination | Out-Null
Assert-Fails {
& "$scripts/Update-SignedArtifacts.ps1" -UnsignedDirectory $unsigned -SignedDirectory $tampered `
-DestinationDirectory $emptyDestination -TestCertificateThumbprint $certificate.Thumbprint
} 'tampered binary'
Assert-NoTemporaryTrust
if (@(Get-ChildItem -LiteralPath $emptyDestination).Count -ne 0) { throw 'Copied files before all checks passed' }
# Build the actual MSI template with fixture binaries; never run this installer.
$msiUnsigned = "$WorkDirectory/msi-unsigned"
$msiSigned = "$WorkDirectory/msi-signed"
New-Item -ItemType Directory -Path $msiUnsigned, $msiSigned | Out-Null
$msiPackage = "$WorkDirectory/msi-package"
Copy-Item -LiteralPath $signed -Destination $msiPackage -Recurse
'{\rtf1\ansi SignPath signature verification fixture. Not for distribution.}' |
Set-Content -LiteralPath "$msiPackage/LICENSE.rtf" -Encoding ASCII
& $heat dir $msiPackage -dr INSTALLFOLDER -cg Package -gg -sreg -srd -var var.SourceDir -out "$WorkDirectory/files.wxs" -sfrag
if ($LASTEXITCODE -ne 0) { throw 'Fixture MSI harvest failed' }
& $candle "-dSourceDir=$msiPackage" '-dInstallerVersion=2.7.63.0' '-dReleaseSuffix=-Signature-Test' `
"$WorkDirectory/build/winInstaller.wxs" "$WorkDirectory/files.wxs" -out "$WorkDirectory/"
if ($LASTEXITCODE -ne 0) { throw 'Fixture MSI compilation failed' }
& $light -b $msiPackage -ext $wixUI "$WorkDirectory/winInstaller.wixobj" "$WorkDirectory/files.wixobj" `
-o "$msiUnsigned/SuperSlicer_fixture.msi" -spdb -sval -sw1076
if ($LASTEXITCODE -ne 0) { throw 'Fixture MSI linking failed' }
Copy-Item -LiteralPath "$msiUnsigned/SuperSlicer_fixture.msi" -Destination $msiSigned
& $signtool.FullName sign /s My /sha1 $certificate.Thumbprint /fd SHA256 "$msiSigned/SuperSlicer_fixture.msi"
if ($LASTEXITCODE -ne 0) { throw 'Fixture MSI signing failed' }
& "$scripts/Update-SignedArtifacts.ps1" -UnsignedDirectory $msiUnsigned -SignedDirectory $msiSigned `
-DestinationDirectory $destination -TestCertificateThumbprint $certificate.Thumbprint
Assert-NoTemporaryTrust
Write-Host 'PASS: signed MSI verified and copied'
# Exercise normal public-root verification without SignPath or our test cert.
$publiclySigned = "$WorkDirectory/publicly-signed"
New-Item -ItemType Directory -Path $publiclySigned | Out-Null
Copy-Item -LiteralPath $signtool.FullName -Destination $publiclySigned
& "$scripts/Update-SignedArtifacts.ps1" -UnsignedDirectory $publiclySigned -SignedDirectory $publiclySigned `
-DestinationDirectory $destination
Write-Host 'PASS: normal Windows trust-chain verification on a Microsoft-signed SDK binary'
} finally {
if ($null -ne $certificate) {
Remove-Item -LiteralPath "Cert:\CurrentUser\My\$($certificate.Thumbprint)" -DeleteKey
}
}
Write-Host 'All local SignPath integration smoke tests passed.'

View file

@ -10,19 +10,45 @@ on:
- nightly_2.7.63
- debug_win
- nightly_win
workflow_dispatch:
env:
# SignPath code signing - see .github/signpath/README.md
# Opt in only after the organization, policy and API secret are ready.
SIGNPATH_ENABLED: ${{ vars.SIGNPATH_ENABLED || 'false' }}
SIGNPATH_ORGANIZATION_ID: ${{ vars.SIGNPATH_ORGANIZATION_ID }}
SIGNPATH_PROJECT_SLUG: ${{ vars.SIGNPATH_PROJECT_SLUG || 'superslicer' }}
SIGNPATH_SIGNING_POLICY_SLUG: ${{ vars.SIGNPATH_SIGNING_POLICY_SLUG }}
SIGNPATH_TEST_CERTIFICATE_THUMBPRINT: ${{ vars.SIGNPATH_TEST_CERTIFICATE_THUMBPRINT }}
jobs:
build_dep:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: check signing configuration
if: env.SIGNPATH_ENABLED == 'true'
shell: powershell
env:
SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}
run: |
foreach ($name in @('SIGNPATH_ORGANIZATION_ID', 'SIGNPATH_PROJECT_SLUG',
'SIGNPATH_SIGNING_POLICY_SLUG', 'SIGNPATH_API_TOKEN')) {
if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) {
throw "Missing $name. See .github/signpath/README.md."
}
}
if ($env:SIGNPATH_TEST_CERTIFICATE_THUMBPRINT -and
($env:SIGNPATH_TEST_CERTIFICATE_THUMBPRINT -replace '\s', '') -notmatch '^[0-9a-fA-F]{40}$') {
throw 'SIGNPATH_TEST_CERTIFICATE_THUMBPRINT must be the SHA-1 thumbprint of the test certificate.'
}
- uses: ilammy/msvc-dev-cmd@v1
- name: mkdir in deps
run: mkdir deps/build
- name: dep cache
id: cache-action
uses: actions/cache@v3
uses: actions/cache@v4
with:
key: win_2.7.63
path: deps/build/destdir
@ -36,9 +62,12 @@ jobs:
build:
runs-on: windows-2022
needs: build_dep
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: update submodule profiles
working-directory: ./resources/profiles
@ -50,7 +79,7 @@ jobs:
(Get-Content version.date.inc) | Foreach-Object {$_ -replace "\+UNKNOWN", ("-" + [datetime]::Today.ToString("yyyy-MM-dd"))} | Set-Content version.date.inc
- name: dep cache
id: cache-action
uses: actions/cache@v3
uses: actions/cache@v4
with:
key: win_2.7.63
path: deps/build/destdir
@ -130,10 +159,52 @@ jobs:
# working-directory: ./build
# shell: cmd
# run: '"C:/Program Files/7-Zip/7z.exe" a -tzip nightly.zip *'
# ---- code signing: own binaries -------------------------------------
# Use an explicit allowlist: src\RelWithDebInfo also contains copied GMP/MPFR DLLs.
- name: collect own binaries to sign
id: signing-input
if: env.SIGNPATH_ENABLED == 'true'
shell: powershell
run: |
./.github/signpath/Prepare-Binaries.ps1 -SourceDirectory build/src/RelWithDebInfo -OutputDirectory build/sign-input
- name: upload unsigned binaries
id: upload-unsigned-binaries
if: env.SIGNPATH_ENABLED == 'true'
uses: actions/upload-artifact@v4
with:
name: unsigned-binaries
path: build/sign-input/
if-no-files-found: error
retention-days: 1
- name: sign binaries
if: env.SIGNPATH_ENABLED == 'true'
uses: signpath/github-action-submit-signing-request@v3
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ env.SIGNPATH_ORGANIZATION_ID }}
project-slug: ${{ env.SIGNPATH_PROJECT_SLUG }}
signing-policy-slug: ${{ env.SIGNPATH_SIGNING_POLICY_SLUG }}
artifact-configuration-slug: windows-binaries
github-artifact-id: ${{ steps.upload-unsigned-binaries.outputs.artifact-id }}
wait-for-completion: true
wait-for-completion-timeout-in-seconds: 1800
output-artifact-directory: build/signed-binaries
parameters: |
version: ${{ toJSON(steps.signing-input.outputs.product-version) }}
- name: verify and copy signed binaries into package
if: env.SIGNPATH_ENABLED == 'true'
shell: powershell
run: |
./.github/signpath/Update-SignedArtifacts.ps1 -UnsignedDirectory build/sign-input -SignedDirectory build/signed-binaries -DestinationDirectory build/package -TestCertificateThumbprint $env:SIGNPATH_TEST_CERTIFICATE_THUMBPRINT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nightly_${{ github.event.repository.name }}-win64
name: ${{ env.SIGNPATH_ENABLED == 'true' && env.SIGNPATH_TEST_CERTIFICATE_THUMBPRINT != '' && 'test-signed_' || '' }}nightly_${{ github.event.repository.name }}-win64
path: build/package/
# MSI CREATION
@ -188,8 +259,49 @@ jobs:
set MSIFileName=${{ github.event.repository.name }}_%InstallerVersion%.msi
candle.exe -dSourceDir="package" -dInstallerVersion="%InstallerVersion%" -dReleaseSuffix="%ReleaseSuffix%" src\winInstaller.wxs files.wxs
light.exe -b package -ext WixUIExtension winInstaller.wixobj files.wixobj -o %MSIFileName% -sw1076
# ---- code signing: installer ----------------------------------------
- name: collect unsigned msi
if: env.SIGNPATH_ENABLED == 'true'
shell: powershell
env:
MSI_FILE_NAME: ${{ github.event.repository.name }}_${{ env.InstallerVersion }}.msi
run: |
New-Item -ItemType Directory -Path build/sign-msi-input | Out-Null
Copy-Item -LiteralPath "build/$env:MSI_FILE_NAME" -Destination build/sign-msi-input -ErrorAction Stop
- name: upload unsigned msi
id: upload-unsigned-msi
if: env.SIGNPATH_ENABLED == 'true'
uses: actions/upload-artifact@v4
with:
name: unsigned-msi
path: build/sign-msi-input/
if-no-files-found: error
retention-days: 1
- name: sign msi
if: env.SIGNPATH_ENABLED == 'true'
uses: signpath/github-action-submit-signing-request@v3
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ env.SIGNPATH_ORGANIZATION_ID }}
project-slug: ${{ env.SIGNPATH_PROJECT_SLUG }}
signing-policy-slug: ${{ env.SIGNPATH_SIGNING_POLICY_SLUG }}
artifact-configuration-slug: windows-msi
github-artifact-id: ${{ steps.upload-unsigned-msi.outputs.artifact-id }}
wait-for-completion: true
wait-for-completion-timeout-in-seconds: 1800
output-artifact-directory: build/signed-msi
- name: verify and replace signed msi
if: env.SIGNPATH_ENABLED == 'true'
shell: powershell
run: |
./.github/signpath/Update-SignedArtifacts.ps1 -UnsignedDirectory build/sign-msi-input -SignedDirectory build/signed-msi -DestinationDirectory build -TestCertificateThumbprint $env:SIGNPATH_TEST_CERTIFICATE_THUMBPRINT
- name: Upload MSI artifact
uses: actions/upload-artifact@v4
with:
name: nightly_${{ github.event.repository.name }}-win64.msi
name: ${{ env.SIGNPATH_ENABLED == 'true' && env.SIGNPATH_TEST_CERTIFICATE_THUMBPRINT != '' && 'test-signed_' || '' }}nightly_${{ github.event.repository.name }}-win64.msi
path: build/${{ github.event.repository.name }}_${{ env.InstallerVersion }}.msi

View file

@ -96,6 +96,12 @@ Sure! You can do the following to find things that are available to help with:
Before sending patches and pull requests contact me (preferably through opening a GitHub issue or commenting on an existing, related, issue) to discuss your proposed
changes. This way we can ensure that nobody wastes their time and no conflicts arise in development.
## Code signing policy
Free code signing provided by [SignPath.io](https://about.signpath.io), certificate by [SignPath Foundation](https://signpath.org).
Windows code signing through SignPath is being set up; existing releases are not retroactively signed. Team roles, signing scope and privacy information are described in the [code signing policy](doc/Code%20signing%20policy.md). See the [integration instructions](.github/signpath/README.md) for the current setup and test-certificate limitations.
## License and attribution
SuperSlicer is licensed under the _GNU Affero General Public License, version 3_.

View file

@ -0,0 +1,43 @@
# Code signing policy
Free code signing provided by [SignPath.io](https://about.signpath.io), certificate by [SignPath Foundation](https://signpath.org).
The SignPath integration is being set up. Older releases and builds from workflows
without signing enabled are not covered. Test-signed artifacts are for integration
testing only, not production releases.
When signing is enabled, only these Windows binaries built from this repository by
GitHub Actions are submitted for signing: `superslicer.exe`, `superslicer_console.exe`,
`superslicer-gcodeviewer.exe`, `Slic3r.dll`, `OCCTWrapper.dll` and the Windows installer.
Everything else shipped in the package — Microsoft Visual C++ runtime, mesa/OpenGL
libraries, GMP/MPFR and other third-party components — is redistributed without being
re-signed with the SuperSlicer certificate; existing upstream signatures are preserved.
## Roles
- Maintainer/committer: [supermerill](https://github.com/supermerill), the owner of this
repository.
- Reviewers: the repository's [code owners](../.github/CODEOWNERS), currently
[supermerill](https://github.com/supermerill) and
[lordofhyphens](https://github.com/lordofhyphens). External pull requests require review
before merge.
- Approvers: [supermerill](https://github.com/supermerill). Each release is approved for
signing by the approver, in SignPath.
## Privacy policy
SuperSlicer can contact GitHub and its content/download services to check for new
releases and download printer and print configuration profiles. Profile downloads may
also contact repositories selected by the user. Automatic update features can be
disabled in the application preferences. These requests expose normal connection
information, such as the user's IP address, to the contacted service; see
[GitHub's privacy statement](https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement)
and the policies of any configured third-party service.
User-configured printer/print-server integrations transmit print files, connection
credentials and other information needed for the requested operations to the selected
printer or service. SuperSlicer does not send telemetry or usage statistics to its
maintainers.
SuperSlicer will not transfer any other information to networked systems unless
specifically requested by the user or the person installing or operating it.

View file

@ -137,6 +137,9 @@ endif ()
if (WIN32)
add_library(Slic3r SHARED PrusaSlicer.cpp PrusaSlicer.hpp)
set(SLIC3R_DLL_NAME "Slic3r")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/Dll.rc.in ${CMAKE_CURRENT_BINARY_DIR}/Slic3r-dll.rc @ONLY)
target_sources(Slic3r PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/Slic3r-dll.rc)
else ()
add_executable(Slic3r PrusaSlicer.cpp PrusaSlicer.hpp)
target_compile_options(Slic3r PRIVATE ${_CC_DEBUG_FLAGS})

View file

@ -8,6 +8,12 @@ else ()
add_library(OCCTWrapper MODULE OCCTWrapper.cpp)
endif ()
if (WIN32)
set(SLIC3R_DLL_NAME "OCCTWrapper")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../platform/msw/Dll.rc.in ${CMAKE_CURRENT_BINARY_DIR}/OCCTWrapper.rc @ONLY)
target_sources(OCCTWrapper PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/OCCTWrapper.rc)
endif ()
set_target_properties(OCCTWrapper
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/src"

View file

@ -0,0 +1,23 @@
1 VERSIONINFO
FILEVERSION @SLIC3R_RC_VERSION@
PRODUCTVERSION @SLIC3R_RC_VERSION@
FILEOS 0x40004
FILETYPE 0x2
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileDescription", "@SLIC3R_APP_NAME@ @SLIC3R_DLL_NAME@ library"
VALUE "FileVersion", "@SLIC3R_BUILD_ID@"
VALUE "ProductName", "@SLIC3R_APP_NAME@"
VALUE "ProductVersion", "@SLIC3R_BUILD_ID@"
VALUE "InternalName", "@SLIC3R_DLL_NAME@"
VALUE "OriginalFilename", "@SLIC3R_DLL_NAME@.dll"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}

View file

@ -9,7 +9,7 @@ PRODUCTVERSION @SLIC3R_RC_VERSION@
VALUE "CompanyName", "Prusa Research"
VALUE "FileDescription", "@GCODEVIEWER_APP_NAME@"
VALUE "FileVersion", "@SLIC3R_BUILD_ID@"
VALUE "ProductName", "@GCODEVIEWER_APP_NAME@"
VALUE "ProductName", "@SLIC3R_APP_NAME@"
VALUE "ProductVersion", "@SLIC3R_BUILD_ID@"
VALUE "InternalName", "@GCODEVIEWER_APP_NAME@"
VALUE "LegalCopyright", "Copyright \251 2019-2025 Durand Remi, \251 2016-2025 Prusa Research, \251 2018-2021 Joseph Lenox, \251 2011-2018 Alessandro Ranellucci"