Accept native Windows TLS negatives with preserved fixture and permanent identity
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-13 23:38:53 +01:00
parent f8488af088
commit 893f4e4900
5 changed files with 74 additions and 10 deletions
+17 -7
View File
@@ -88,18 +88,28 @@ if ($p.action -eq 'prepare') {
$value=$raw | ConvertFrom-Json
[pscustomobject]@{exit_code=$code;probe=$value} | ConvertTo-Json -Depth 8 -Compress
} else {
$state='C:\ProgramData\RustDiscovery\state'
throw 'Witness uses the separate bounded read-only script'
}
}
'''
WITNESS=r'''
$ErrorActionPreference='Stop'
$p=([Console]::In.ReadLine() | ConvertFrom-Json)
if ($p.id -notmatch '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' -or $p.sha256 -notmatch '^[0-9a-f]{64}$') {throw 'Fixed witness binding'}
$binary='C:\ProgramData\RustDiscoveryBootstrap\'+$p.sha256+'\WindowsTlsProbe.exe'
if ((Get-FileHash -LiteralPath $binary -Algorithm SHA256).Hash.ToLowerInvariant() -cne $p.sha256) {throw 'Exact witness artifact'}
$state='C:\ProgramData\RustDiscovery\state'
$identity=Get-Content -LiteralPath (Join-Path $state 'identity.json') -Raw | ConvertFrom-Json
$files=[ordered]@{}
foreach($name in @('identity.json','device.pem')) {$files[$name]=(Get-FileHash -LiteralPath (Join-Path $state $name) -Algorithm SHA256).Hash.ToLowerInvariant()}
$key=Get-Item -LiteralPath (Join-Path $state 'device.key')
$service=Get-CimInstance Win32_Service -Filter "Name='RmmDiscoveryWindows'"
$service=Get-CimInstance Win32_Service -OperationTimeoutSec 10 -Filter "Name='RmmDiscoveryWindows'"
[pscustomobject]@{identity=[ordered]@{agent_id=$identity.agent_id;asset_id=$identity.asset_id};public_file_hashes=$files;
private_key_metadata=[ordered]@{length=$key.Length;creation_ticks=$key.CreationTimeUtc.Ticks;last_write_ticks=$key.LastWriteTimeUtc.Ticks};
service=[ordered]@{state=$service.State;start_name=$service.StartName;process_id=$service.ProcessId};
existing_private_key_read=$false;bootstrap_admin_tls_probe=$true} | ConvertTo-Json -Depth 8 -Compress
}
}
'''
@@ -160,7 +170,7 @@ def main():
signed=originals['signed-public.json'];before=originals['permanent-before.json']
require(signed['id']==ident and dt.datetime.fromisoformat(signed['valid_not_after'])>dt.datetime.now(dt.timezone.utc)+dt.timedelta(minutes=2),
'existing positive certificate must remain valid; never resign or alter clock during retest')
require(cb.powershell(REMOTE,dict(action='witness',id=ident,sha256=sha))==before,'original permanent witness unchanged before retest')
require(cb.powershell(WITNESS,dict(id=ident,sha256=sha),timeout=25)==before,'original permanent witness unchanged before retest')
checked=cb.powershell(REMOTE,dict(action='verify-public',id=ident,sha256=sha,hashes=originals['public-transfer.json']['public_files_sha256']))
require(checked.get('verified') is True,'unchanged original public fixture certificates')
write(folder/'original-evidence.json',dict(id=ident,retained=True,original_files_sha256={name:hashlib.sha256((original/name).read_bytes()).hexdigest() for name in originals},
@@ -172,7 +182,7 @@ def main():
prepared=cb.powershell(REMOTE,dict(action='prepare',id=ident,sha256=sha));write(folder/'prepared.json',prepared)
require(prepared['prepared'] and prepared['case_id']==ident and not prepared['private_key_exported'],'Windows-only fixture key and public CSR')
csr=prepared['csr_pem'].encode();require(len(csr)<8192 and hashlib.sha256(csr).hexdigest()==prepared['csr_sha256'],'bounded original public CSR')
before=cb.powershell(REMOTE,dict(action='witness',id=ident,sha256=sha));write(folder/'permanent-before.json',before)
before=cb.powershell(WITNESS,dict(id=ident,sha256=sha),timeout=25);write(folder/'permanent-before.json',before)
gate_before=bootstrap.rpc('server.conf',expiry.server_gate,dict(id=ident));write(folder/'server-before.json',gate_before)
require(gate_before==dict(installations=0,jobs=0,outbox=0,permits=0),'unregistered fixture and zero jobs')
signed=bootstrap.rpc('server.conf',expiry.sign_server,dict(id=ident,csr=base64.b64encode(csr).decode()));write(folder/'signed-public.json',signed)
@@ -184,7 +194,7 @@ def main():
write(folder/(label+'.json'),outcome);probes.append(dict(label=label,**outcome))
require(outcome['exit_code']==0 and outcome['probe'].get('verified') is True
and outcome['probe']['case_id']==ident and outcome['probe']['kind']==kind,'native exact TLS outcome; timeout/unclassified error is not a TLS denial')
after=cb.powershell(REMOTE,dict(action='witness',id=ident,sha256=sha));write(folder/'permanent-after.json',after)
after=cb.powershell(WITNESS,dict(id=ident,sha256=sha),timeout=25);write(folder/'permanent-after.json',after)
require(after==before,'permanent service identity/key metadata/public files unchanged')
gate_after=bootstrap.rpc('server.conf',expiry.server_gate,dict(id=ident));write(folder/'server-after.json',gate_after)
require(gate_after==gate_before,'no fixture registration/jobs/grants')