Files
kinect/attach/windows/scripts/Enable-TestSigning.ps1
T
kinect-bot 9b5a0255e2
ci / Linux C++ core (cmake + ctest) (push) Canceled after 0s
ci / Python root tests (pytest, no tracker deps) (push) Canceled after 0s
ci / Python tracker (pytest, tracker/.venv) (push) Canceled after 0s
feat(windows): usbip-win runbook ([~]) + clean-room Kinect10.dll NUI shim (x86+x64 export-verified) (wave 9; todo 14 done, 12/13 blocked)
2026-11-25 06:00:12 -05:00

78 lines
4.0 KiB
PowerShell

#requires -Version 5.1
<#
.SYNOPSIS
Enable Windows test-signing and import the usbip-win test certificate so a test-signed VHCI
driver loads. Personal-use only; this weakens driver-signature enforcement.
.DESCRIPTION
[~] BLOCKED in the kinect build environment (no Windows). RUN THIS ON THE USER'S WINDOWS BOX,
elevated. Needed only for the legacy cezanne usbip-win (test-signed) client. The recommended
usbip-win2 UDE driver is attestation/WHLK-signed and typically needs NONE of this.
What test-signing is and why it is needed:
Windows x64 refuses to load kernel-mode drivers that are not signed by a certificate chaining
to a Microsoft-trusted root. A self-built / test-signed VHCI driver is signed by a TEST
certificate, not a trusted CA, so Windows blocks it until the machine is put into test-signing
mode AND the test certificate is trusted. Secure Boot enforces the same policy in firmware and
must be OFF for test-signing to take effect.
SECURITY / SCOPE: this is a personal-use development posture, NOT production. A test-signed
driver is unsigned for trust purposes. Re-enable Secure Boot and disable test-signing when done
(Disable-TestSigning.ps1) -- but NOT while the test-signed VHCI driver is still installed, or
every USB device bound through it stops working.
.PARAMETER PfxPath
Path to usbip_test.pfx from the usbip-win release (password: usbip). Imported into the LOCAL
COMPUTER "Trusted Root Certification Authorities" and "Trusted Publishers" stores.
#>
[CmdletBinding()]
param(
[string]$PfxPath
)
$ErrorActionPreference = 'Stop'
function Assert-Admin {
$id = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($id)
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw 'This script must run in an elevated PowerShell (Run as Administrator).'
}
}
Assert-Admin
# 1. Secure Boot must be off for test-signing to take effect.
try {
$secureBoot = Confirm-SecureBootUEFI
if ($secureBoot) {
Write-Warning 'Secure Boot is ON. Test-signing will NOT take effect until you disable Secure Boot in UEFI/BIOS firmware.'
Write-Warning 'Reboot into firmware setup, turn Secure Boot off, then re-run this script.'
} else {
Write-Host 'Secure Boot is off -- good; test-signing can take effect.' -ForegroundColor Green
}
} catch {
Write-Host 'Could not query Secure Boot (legacy BIOS or cmdlet unavailable). If this is a UEFI box, verify Secure Boot is OFF manually.' -ForegroundColor Yellow
}
# 2. Enable test-signing.
Write-Host 'Enabling test-signing: bcdedit /set testsigning on' -ForegroundColor Green
bcdedit.exe /set testsigning on
if ($LASTEXITCODE -ne 0) { throw 'bcdedit /set testsigning on failed (not elevated, or BitLocker/Secure Boot blocking).' }
# 3. Import the test certificate into the LOCAL COMPUTER stores (both are required).
if ($PfxPath) {
if (-not (Test-Path $PfxPath)) { throw "PFX not found: $PfxPath" }
$pwd = ConvertTo-SecureString -String 'usbip' -AsPlainText -Force
Write-Host "Importing $PfxPath into LocalMachine\Root and LocalMachine\TrustedPublisher ..." -ForegroundColor Green
Import-PfxCertificate -FilePath $PfxPath -CertStoreLocation 'Cert:\LocalMachine\Root' -Password $pwd | Out-Null
Import-PfxCertificate -FilePath $PfxPath -CertStoreLocation 'Cert:\LocalMachine\TrustedPublisher' -Password $pwd | Out-Null
Write-Host 'Test certificate imported into both required local-computer stores.' -ForegroundColor Green
} else {
Write-Host 'No -PfxPath given. For the legacy usbip-win client, import usbip_test.pfx (password: usbip) into BOTH' -ForegroundColor Yellow
Write-Host 'LocalMachine "Trusted Root Certification Authorities" AND "Trusted Publishers" before installing the driver.' -ForegroundColor Yellow
}
Write-Host ''
Write-Host 'REBOOT NOW for test-signing to take effect. A "Test Mode" watermark will appear on the desktop -- expected.' -ForegroundColor Cyan