Preserve native TLS refusal evidence and qualify typed Windows error classification
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -0,0 +1,268 @@
|
||||
//! Explicit development TLS fixture only. No enrollment, service or job path.
|
||||
//! The fixture private key is generated and retained on this Windows guest.
|
||||
#[cfg(windows)]
|
||||
#[path = "../../agent/src/https_channel.rs"]
|
||||
pub mod https_channel;
|
||||
|
||||
#[cfg(any(windows, test))]
|
||||
mod tls_errors {
|
||||
use std::error::Error;
|
||||
pub(super) fn classify(error: &(dyn Error + 'static)) -> &'static str {
|
||||
let mut next = Some(error);
|
||||
for _ in 0..16 {
|
||||
let Some(current) = next else { break };
|
||||
if let Some(tls) = current.downcast_ref::<rustls::Error>() {
|
||||
return match tls {
|
||||
rustls::Error::AlertReceived(rustls::AlertDescription::CertificateExpired) => {
|
||||
"TLS_PEER_CERTIFICATE_EXPIRED"
|
||||
}
|
||||
rustls::Error::InvalidCertificate(rustls::CertificateError::UnknownIssuer) => {
|
||||
"TLS_UNKNOWN_ISSUER"
|
||||
}
|
||||
rustls::Error::InvalidCertificate(
|
||||
rustls::CertificateError::NotValidForName
|
||||
| rustls::CertificateError::NotValidForNameContext { .. },
|
||||
) => "TLS_SERVER_NAME_MISMATCH",
|
||||
rustls::Error::InvalidCertificate(_) => "TLS_OTHER_INVALID_CERTIFICATE",
|
||||
rustls::Error::AlertReceived(_) => "TLS_OTHER_PEER_ALERT",
|
||||
_ => "TLS_OTHER_ERROR",
|
||||
};
|
||||
}
|
||||
// io::Error::source skips its boxed payload itself. Inspect get_ref
|
||||
// first to preserve the concrete rustls::Error inside nested TLS I/O.
|
||||
next = current
|
||||
.downcast_ref::<std::io::Error>()
|
||||
.and_then(std::io::Error::get_ref)
|
||||
.map(|inner| inner as &(dyn Error + 'static))
|
||||
.or_else(|| current.source());
|
||||
}
|
||||
"UNCLASSIFIED_TRANSPORT_ERROR"
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn nested_io_preserves_typed_tls_and_rejects_untyped_failures() {
|
||||
use std::io::{Error as IoError, ErrorKind};
|
||||
let cases = [
|
||||
(
|
||||
rustls::Error::InvalidCertificate(rustls::CertificateError::UnknownIssuer),
|
||||
"TLS_UNKNOWN_ISSUER",
|
||||
),
|
||||
(
|
||||
rustls::Error::InvalidCertificate(rustls::CertificateError::NotValidForName),
|
||||
"TLS_SERVER_NAME_MISMATCH",
|
||||
),
|
||||
(
|
||||
rustls::Error::AlertReceived(rustls::AlertDescription::CertificateExpired),
|
||||
"TLS_PEER_CERTIFICATE_EXPIRED",
|
||||
),
|
||||
];
|
||||
for (error, expected) in cases {
|
||||
// Tokio-rustls wraps InvalidData; hyper-rustls wraps it again as Other.
|
||||
let nested = IoError::other(IoError::new(ErrorKind::InvalidData, error));
|
||||
assert_eq!(classify(&nested), expected);
|
||||
}
|
||||
for error in [
|
||||
IoError::from(ErrorKind::TimedOut),
|
||||
IoError::from(ErrorKind::ConnectionReset),
|
||||
IoError::other("certificate has expired: UnknownIssuer"),
|
||||
] {
|
||||
assert_eq!(classify(&error), "UNCLASSIFIED_TRANSPORT_ERROR");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
mod probe {
|
||||
use anyhow::{Result, ensure};
|
||||
use rcgen::{BasicConstraints, CertificateParams, DnType, IsCa, KeyPair};
|
||||
use serde_json::{Value, json};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{fs, io::Write, path::Path};
|
||||
use uuid::Uuid;
|
||||
|
||||
const ROOT: &str = r"C:\ProgramData\RustDiscoveryBootstrap\tls-negative";
|
||||
const SERVER: &str = "discovery.ease-technologies.de";
|
||||
|
||||
fn private_read(root: &Path, name: &str, maximum: usize) -> Result<Vec<u8>> {
|
||||
let path = root.join(name);
|
||||
rmm_agent_windows::native::private_path(&path, false)?;
|
||||
ensure!(
|
||||
fs::metadata(&path)?.len() <= maximum as u64,
|
||||
"FIXTURE_FILE_LIMIT"
|
||||
);
|
||||
Ok(fs::read(path)?)
|
||||
}
|
||||
fn create(root: &Path, name: &str, bytes: &[u8]) -> Result<()> {
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.create_new(true)
|
||||
.write(true)
|
||||
.open(root.join(name))?;
|
||||
file.write_all(bytes)?;
|
||||
file.sync_all()?;
|
||||
Ok(())
|
||||
}
|
||||
fn prepare(root: &Path, id: Uuid) -> Result<Value> {
|
||||
ensure!(
|
||||
fs::read_dir(root)?.next().is_none(),
|
||||
"FRESH_FIXTURE_DIRECTORY_REQUIRED"
|
||||
);
|
||||
let key = KeyPair::generate()?;
|
||||
let mut params = CertificateParams::default();
|
||||
params
|
||||
.distinguished_name
|
||||
.push(DnType::CommonName, id.to_string());
|
||||
let csr = params.serialize_request(&key)?.pem()?;
|
||||
ensure!(csr.len() < 8192, "FIXTURE_CSR_LIMIT");
|
||||
// Never emit or transfer the private key. Parent directory has already
|
||||
// been restricted to SYSTEM/Administrators by the bootstrap wrapper.
|
||||
create(root, "fixture.key", key.serialize_pem().as_bytes())?;
|
||||
create(root, "fixture.csr", csr.as_bytes())?;
|
||||
let mut wrong = CertificateParams::default();
|
||||
wrong.is_ca = IsCa::Ca(BasicConstraints::Unconstrained);
|
||||
wrong
|
||||
.distinguished_name
|
||||
.push(DnType::CommonName, "RMM unrelated fixture CA");
|
||||
let wrong_key = KeyPair::generate()?;
|
||||
create(
|
||||
root,
|
||||
"wrong-ca.pem",
|
||||
wrong.self_signed(&wrong_key)?.pem().as_bytes(),
|
||||
)?;
|
||||
create(
|
||||
root,
|
||||
"case.json",
|
||||
&serde_json::to_vec(&json!({"schema_version":1,"case_id":id}))?,
|
||||
)?;
|
||||
Ok(
|
||||
json!({"prepared":true,"case_id":id,"csr_pem":csr,"csr_sha256":format!("{:x}",Sha256::digest(csr.as_bytes())),
|
||||
"private_key_exported":false,"enrollment_created":false,"jobs_created":false}),
|
||||
)
|
||||
}
|
||||
async fn request(root: &Path, id: Uuid, kind: &str) -> Result<Value> {
|
||||
let marker: Value = serde_json::from_slice(&private_read(root, "case.json", 1024)?)?;
|
||||
ensure!(
|
||||
marker == json!({"schema_version":1,"case_id":id}),
|
||||
"FIXTURE_ID_BINDING"
|
||||
);
|
||||
let ca = private_read(
|
||||
root,
|
||||
if kind == "wrong-ca" {
|
||||
"wrong-ca.pem"
|
||||
} else {
|
||||
"issuer-ca.pem"
|
||||
},
|
||||
32768,
|
||||
)?;
|
||||
let certificate = private_read(
|
||||
root,
|
||||
if kind == "expired" {
|
||||
"expired.pem"
|
||||
} else {
|
||||
"valid.pem"
|
||||
},
|
||||
32768,
|
||||
)?;
|
||||
let key = private_read(root, "fixture.key", 16384)?;
|
||||
let address = "88.99.80.202:443".parse()?;
|
||||
// Exactly the production transport builder: configured CA only,
|
||||
// verified DNS/SNI, mTLS, no proxy trust, redirects or invalid-cert mode.
|
||||
let client = crate::https_channel::mtls_client(address, &ca, &certificate, &key)?;
|
||||
let name = crate::https_channel::server_name()?;
|
||||
let result = client
|
||||
.post(format!("https://{name}:443/agent/v1/messages"))
|
||||
.header(reqwest::header::CONTENT_TYPE, "application/x-protobuf")
|
||||
.body(Vec::new())
|
||||
.send()
|
||||
.await;
|
||||
let (status, code) = match result {
|
||||
Ok(response) => (Some(response.status().as_u16()), "HTTP_RESPONSE"),
|
||||
Err(error) if error.is_timeout() => (None, "TRANSPORT_TIMEOUT"),
|
||||
Err(error) => (None, super::tls_errors::classify(&error)),
|
||||
};
|
||||
let expected = match kind {
|
||||
"valid" => status == Some(401),
|
||||
"expired" => status.is_none() && code == "TLS_PEER_CERTIFICATE_EXPIRED",
|
||||
"wrong-ca" => status.is_none() && code == "TLS_UNKNOWN_ISSUER",
|
||||
"wrong-name" => status.is_none() && code == "TLS_SERVER_NAME_MISMATCH",
|
||||
_ => false,
|
||||
};
|
||||
Ok(
|
||||
json!({"case_id":id,"kind":kind,"verified":expected,"http_status":status,"code":code,
|
||||
"native_windows":true,"execution_context":"bootstrap_administrator_tls_probe",
|
||||
"shared_https_client":true,"certificate_verification_disabled":false,"clock_adjusted":false,
|
||||
"private_key_exported":false,"enrollment_created":false,"jobs_created":false}),
|
||||
)
|
||||
}
|
||||
pub fn run() -> Result<Value> {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
ensure!(
|
||||
(args.len() == 2 && args[0] == "prepare") || (args.len() == 3 && args[0] == "probe"),
|
||||
"FIXED_PROBE_ARGUMENTS"
|
||||
);
|
||||
let id = Uuid::parse_str(&args[1])?;
|
||||
ensure!(
|
||||
!id.is_nil() && id.to_string() == args[1],
|
||||
"CANONICAL_FIXTURE_UUID"
|
||||
);
|
||||
let root = Path::new(ROOT).join(id.to_string());
|
||||
rmm_agent_windows::native::private_path(Path::new(ROOT), true)?;
|
||||
rmm_agent_windows::native::private_path(&root, true)?;
|
||||
if args[0] == "prepare" {
|
||||
return prepare(&root, id);
|
||||
}
|
||||
let kind = args[2].as_str();
|
||||
ensure!(
|
||||
matches!(kind, "valid" | "expired" | "wrong-ca" | "wrong-name"),
|
||||
"FIXED_PROBE_KIND"
|
||||
);
|
||||
// SAFETY: one freshly launched process per kind, before constructing
|
||||
// Tokio or any worker threads. No environment mutation during a runtime.
|
||||
unsafe {
|
||||
std::env::set_var(
|
||||
"RMM_SERVER_NAME",
|
||||
if kind == "wrong-name" {
|
||||
"wrong-name.invalid"
|
||||
} else {
|
||||
SERVER
|
||||
},
|
||||
);
|
||||
}
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()?;
|
||||
runtime.block_on(request(&root, id, kind))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() {
|
||||
match probe::run() {
|
||||
Ok(value) => {
|
||||
let accepted = value
|
||||
.get("prepared")
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or(false)
|
||||
|| value
|
||||
.get("verified")
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or(false);
|
||||
println!("{value}");
|
||||
if !accepted {
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::json!({"verified":false,"code":"WINDOWS_TLS_FIXTURE_INCOMPLETE"})
|
||||
);
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
eprintln!("Windows TLS fixture probe requires native Windows");
|
||||
std::process::exit(1);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ def powershell(script, payload=None, timeout=60, remote_signed=False):
|
||||
UPLOAD = r'''
|
||||
$ErrorActionPreference='Stop'
|
||||
$p=([Console]::In.ReadLine() | ConvertFrom-Json)
|
||||
if ($p.name -notmatch '^((rmm-agent-windows|windows-tests-(lib|bin|acl))\.exe|Install-PassiveClient\.ps1|PassiveStateProbe\.exe)$') {throw 'Artifact allowlist'}
|
||||
if ($p.name -notmatch '^((rmm-agent-windows|windows-tests-(lib|bin|acl))\.exe|Install-PassiveClient\.ps1|PassiveStateProbe\.exe|WindowsTlsProbe\.exe)$') {throw 'Artifact allowlist'}
|
||||
$root='C:\ProgramData\RustDiscoveryBootstrap'
|
||||
if (!(Test-Path -LiteralPath $root)) {
|
||||
New-Item -ItemType Directory -Path $root | Out-Null
|
||||
@@ -68,7 +68,7 @@ if (Test-Path -LiteralPath $path) {throw 'Artifact already exists'}
|
||||
VERIFY_UPLOAD = r'''
|
||||
$ErrorActionPreference='Stop'
|
||||
$p=([Console]::In.ReadLine() | ConvertFrom-Json)
|
||||
if ($p.sha256 -notmatch '^[0-9a-f]{64}$' -or $p.name -notmatch '^((rmm-agent-windows|windows-tests-(lib|bin|acl))\.exe|Install-PassiveClient\.ps1|PassiveStateProbe\.exe)$') {throw 'Artifact allowlist'}
|
||||
if ($p.sha256 -notmatch '^[0-9a-f]{64}$' -or $p.name -notmatch '^((rmm-agent-windows|windows-tests-(lib|bin|acl))\.exe|Install-PassiveClient\.ps1|PassiveStateProbe\.exe|WindowsTlsProbe\.exe)$') {throw 'Artifact allowlist'}
|
||||
$path='C:\ProgramData\RustDiscoveryBootstrap\'+$p.sha256+'\'+$p.name
|
||||
$hash=(Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||
if ($hash -cne $p.sha256) {throw 'Artifact hash'}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Explicit native Admin TLS negatives; permanent Windows service stays passive.
|
||||
|
||||
Only public CSR leaves Windows. Only public certificates are sent to Windows.
|
||||
No enrollment, jobs, clock adjustment, identity replacement or TLS bypass.
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
import datetime as dt
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import uuid
|
||||
|
||||
import client_bootstrap as cb
|
||||
import cloud_tls_expiry_acceptance as expiry
|
||||
import remote_client_bootstrap as bootstrap
|
||||
|
||||
require=cb.contract.require
|
||||
STATE=cb.EVIDENCE/'tls-negative'
|
||||
|
||||
REMOTE=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 fixture binding'}
|
||||
if ($p.action -notin @('prepare','incoming','seal-public','verify-public','probe','witness')) {throw 'Fixed action'}
|
||||
$binary='C:\ProgramData\RustDiscoveryBootstrap\'+$p.sha256+'\WindowsTlsProbe.exe'
|
||||
if ((Get-FileHash -LiteralPath $binary -Algorithm SHA256).Hash.ToLowerInvariant() -cne $p.sha256) {throw 'Probe artifact changed'}
|
||||
$base='C:\ProgramData\RustDiscoveryBootstrap\tls-negative'
|
||||
$folder=Join-Path $base $p.id
|
||||
$allowed=@('S-1-5-18','S-1-5-32-544')
|
||||
function Assert-Directory([string]$Path) {
|
||||
$item=Get-Item -LiteralPath $Path
|
||||
if (!$item.PSIsContainer -or (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0)) {throw 'Private regular directory'}
|
||||
$acl=Get-Acl -LiteralPath $Path
|
||||
if (!$acl.AreAccessRulesProtected -or $acl.GetOwner([Security.Principal.SecurityIdentifier]).Value -notin $allowed) {throw 'Private directory owner'}
|
||||
foreach($rule in $acl.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier])) {
|
||||
if ($rule.IdentityReference.Value -notin $allowed -or $rule.AccessControlType -ne 'Allow') {throw 'Private directory ACL'}
|
||||
}
|
||||
}
|
||||
function New-Directory([string]$Path) {
|
||||
New-Item -ItemType Directory -Path $Path | Out-Null
|
||||
$acl=New-Object Security.AccessControl.DirectorySecurity
|
||||
$acl.SetAccessRuleProtection($true,$false)
|
||||
$acl.SetOwner((New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')))
|
||||
foreach($sid in $allowed) {$acl.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule((New-Object Security.Principal.SecurityIdentifier($sid)),'FullControl','ContainerInherit,ObjectInherit','None','Allow')))}
|
||||
Set-Acl -LiteralPath $Path -AclObject $acl
|
||||
Assert-Directory $Path
|
||||
}
|
||||
function Seal-Files {
|
||||
foreach($item in Get-ChildItem -LiteralPath $folder) {
|
||||
if ($item.PSIsContainer -or (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0)) {throw 'Fixture regular file'}
|
||||
$acl=New-Object Security.AccessControl.FileSecurity
|
||||
$acl.SetAccessRuleProtection($true,$false)
|
||||
$acl.SetOwner((New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')))
|
||||
foreach($sid in $allowed) {$acl.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule((New-Object Security.Principal.SecurityIdentifier($sid)),'FullControl','Allow')))}
|
||||
Set-Acl -LiteralPath $item.FullName -AclObject $acl
|
||||
}
|
||||
}
|
||||
if ($p.action -eq 'prepare') {
|
||||
if (!(Test-Path -LiteralPath $base)) {New-Directory $base}
|
||||
Assert-Directory $base
|
||||
if (Test-Path -LiteralPath $folder) {throw 'Fixture already exists; preserve, never repeat blindly'}
|
||||
New-Directory $folder
|
||||
$raw=& $binary prepare $p.id; $code=$LASTEXITCODE
|
||||
Seal-Files
|
||||
if ($code -ne 0) {throw 'Fixture preparation failed'}
|
||||
$value=$raw | ConvertFrom-Json
|
||||
if (!$value.prepared -or $value.case_id -cne $p.id -or $value.private_key_exported) {throw 'Public CSR response'}
|
||||
$value | ConvertTo-Json -Depth 8 -Compress
|
||||
} else {
|
||||
Assert-Directory $base; Assert-Directory $folder
|
||||
if ($p.action -eq 'incoming') {
|
||||
foreach($name in @('issuer-ca.pem','valid.pem','expired.pem')) {if (Test-Path -LiteralPath (Join-Path $folder $name)) {throw 'Public certificate already exists'}}
|
||||
[pscustomobject]@{prepared=$true;public_certificates_only=$true} | ConvertTo-Json -Compress
|
||||
} elseif ($p.action -in @('seal-public','verify-public')) {
|
||||
foreach($name in @('issuer-ca.pem','valid.pem','expired.pem')) {
|
||||
$path=Join-Path $folder $name
|
||||
if ((Get-Item -LiteralPath $path).Length -gt 32768 -or (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant() -cne $p.hashes.$name) {throw 'Exact public certificate hash'}
|
||||
}
|
||||
if ($p.action -eq 'seal-public') {Seal-Files}
|
||||
[pscustomobject]@{verified=$true;public_certificates_only=$true} | ConvertTo-Json -Compress
|
||||
} elseif ($p.action -eq 'probe') {
|
||||
if ($p.kind -notin @('valid','expired','wrong-ca','wrong-name')) {throw 'Fixed probe kind'}
|
||||
$raw=& $binary probe $p.id $p.kind; $code=$LASTEXITCODE
|
||||
$value=$raw | ConvertFrom-Json
|
||||
[pscustomobject]@{exit_code=$code;probe=$value} | ConvertTo-Json -Depth 8 -Compress
|
||||
} else {
|
||||
$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'"
|
||||
[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
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
def write(path,value):
|
||||
fd=os.open(path,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,0o600)
|
||||
with os.fdopen(fd,'w') as stream:json.dump(value,stream,indent=2);stream.write('\n');stream.flush();os.fsync(stream.fileno())
|
||||
|
||||
|
||||
def public_transfer(folder,ident,sha,signed):
|
||||
raw={'issuer-ca.pem':base64.b64decode(signed['ca'],validate=True)}
|
||||
require(set(signed['certificates'])=={'valid','expired'},'exact two public fixture leaves')
|
||||
raw.update({name+'.pem':base64.b64decode(data,validate=True) for name,data in signed['certificates'].items()})
|
||||
for name,data in raw.items():
|
||||
require(100<=len(data)<=32768 and b'PRIVATE KEY' not in data,'public certificates only')
|
||||
path=folder/name;fd=os.open(path,os.O_CREAT|os.O_EXCL|os.O_WRONLY,0o600)
|
||||
with os.fdopen(fd,'wb') as stream:stream.write(data);stream.flush();os.fsync(stream.fileno())
|
||||
cb.powershell(REMOTE,dict(action='incoming',id=ident,sha256=sha))
|
||||
access=cb.contract.protected_json(cb.ROOT/'credentials/windows-dev-access.json');prefix=access['ssh_prefix']
|
||||
args=['sftp']+[part for part in prefix[1:-1] if part!='-T']+['-b','-',prefix[-1]]
|
||||
remote='/C:/ProgramData/RustDiscoveryBootstrap/tls-negative/'+ident+'/'
|
||||
# Fixed public files only. There is deliberately no SFTP get/download path.
|
||||
batch=''.join('put '+json.dumps(str((folder/name).resolve()))+' '+json.dumps(remote+name)+'\n' for name in raw)
|
||||
require(subprocess.run(args,input=batch.encode(),capture_output=True,timeout=60).returncode==0,'public certificate SFTP failed')
|
||||
hashes={name:hashlib.sha256(data).hexdigest() for name,data in raw.items()}
|
||||
result=cb.powershell(REMOTE,dict(action='seal-public',id=ident,sha256=sha,hashes=hashes))
|
||||
require(result.get('verified') is True,'public fixture ACL/hash verification')
|
||||
return dict(public_files_sha256=hashes,sftp_upload_only=True,private_key_transferred=False)
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--execute-native-tls-negative',action='store_true',required=True)
|
||||
parser.add_argument('--artifact',type=Path,required=True)
|
||||
parser.add_argument('--resume-case',type=uuid.UUID,help='Read-only TLS retest of existing fixtures, preserving every original receipt')
|
||||
args=parser.parse_args();os.umask(0o077)
|
||||
artifact=args.artifact.resolve();qualification=cb.contract.protected_json(Path(str(artifact)+'.json'))
|
||||
sha=hashlib.sha256(artifact.read_bytes()).hexdigest()
|
||||
require(qualification['binary_sha256']==sha and qualification['release_build'] is True
|
||||
and qualification['architecture']=='x86_64-pc-windows-gnu'
|
||||
and all(hashlib.sha256((cb.ROOT/p).read_bytes()).hexdigest()==h for p,h in qualification['source_files'].items()),'qualified exact Windows TLS probe artifact')
|
||||
STATE.mkdir(mode=0o700,parents=True,exist_ok=True)
|
||||
ident=str(args.resume_case or uuid.uuid4())
|
||||
original=STATE/ident
|
||||
if args.resume_case:
|
||||
require(original.is_dir() and not original.is_symlink(),'existing original private case')
|
||||
folder=original/('typed-retest-'+str(uuid.uuid4()))
|
||||
else:folder=original
|
||||
folder.mkdir(mode=0o700)
|
||||
write(folder/'started.json',dict(id=ident,artifact_sha256=sha,execution_context='bootstrap_administrator_tls_probe',no_service_or_identity_mutations=True))
|
||||
pointer=cb.EVIDENCE/'WindowsTlsProbe.exe.latest.json'
|
||||
if pointer.exists() and cb.contract.protected_json(pointer)['sha256']==sha:
|
||||
cb.powershell(cb.VERIFY_UPLOAD,dict(name='WindowsTlsProbe.exe',sha256=sha))
|
||||
else:cb.upload(artifact,'WindowsTlsProbe.exe')
|
||||
if args.resume_case:
|
||||
originals={name:cb.contract.protected_json(original/name) for name in ('started.json','prepared.json','signed-public.json','public-transfer.json','permanent-before.json','wrong-ca.json')}
|
||||
require(originals['started.json']['id']==ident and originals['wrong-ca.json']['exit_code']==2
|
||||
and originals['wrong-ca.json']['probe']['verified'] is False,'exact preserved failed case')
|
||||
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')
|
||||
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},
|
||||
original_artifact_sha256=originals['started.json']['artifact_sha256'],replacement_artifact_sha256=sha,
|
||||
no_new_csr=True,no_signing=True,no_fixture_transfer=True))
|
||||
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 original fixture')
|
||||
else:
|
||||
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)
|
||||
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)
|
||||
require(signed['id']==ident and signed['ca_unchanged'] and not signed['clock_adjusted'] and not signed['enrollment_created'],'existing CA unchanged and no clock/enrollment mutation')
|
||||
transfer=public_transfer(folder,ident,sha,signed);write(folder/'public-transfer.json',transfer)
|
||||
probes=[]
|
||||
for label,kind in (('valid-before','valid'),('wrong-ca','wrong-ca'),('wrong-name','wrong-name'),('expired','expired'),('valid-after','valid')):
|
||||
outcome=cb.powershell(REMOTE,dict(action='probe',id=ident,sha256=sha,kind=kind),timeout=50)
|
||||
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)
|
||||
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')
|
||||
write(folder/'result.json',dict(verified=True,id=ident,probes=probes,server_gate=gate_after,permanent_identity_preserved=True,
|
||||
private_key_exported=False,enrollment_created=False,jobs_created=False,clock_adjusted=False,
|
||||
execution_context='bootstrap_administrator_tls_probe',local_service_probe=False,artifact_sha256=sha))
|
||||
print(json.dumps(dict(verified=True,id=ident,evidence_directory=str(folder),probes=5,private_key_exported=False,local_service_probe=False,jobs_created=False)))
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
try:main()
|
||||
except Exception as error:
|
||||
print('WINDOWS_TLS_ACCEPTANCE_INCOMPLETE:'+type(error).__name__)
|
||||
raise SystemExit(2) from None
|
||||
@@ -1,5 +1,25 @@
|
||||
# Tatsächlicher Implementierungsstand
|
||||
|
||||
## Windows-TLS: gültige Kontrolle bestanden, Negativklassifikation korrigiert
|
||||
|
||||
Native getrennte Admin-TLS-Fixture7b190a5c-c928-4348-bd0d-c9698dad5417 erzeugte
|
||||
ihren Schlüssel ausschließlich auf Windows. Nur öffentliche CSR zum Server,
|
||||
öffentliche CA/Clientzertifikate zurück. Gültige unregistrierte Kontrolle
|
||||
erreichte HTTP401. Falsche CA endete ohne HTTP, aber als
|
||||
UNCLASSIFIED_TRANSPORT_ERROR; deshalb ausdrücklich keine erfolgreiche
|
||||
TLS-Negativabnahme. Readonly-Folgenachweis bestätigt unveränderten permanenten
|
||||
Dienst/PID/Identität und private Keydateimetadaten, keine Registrierung/Jobs.
|
||||
|
||||
Exakte gelockte Bibliotheksquellen erklären die verlorene Typidentität: zwei
|
||||
verschachtelte io::Error um den tatsächlichen Rustlsfehler. Prüfer folgt jetzt
|
||||
get_ref vor source, ohne String-/Timeout-/Resetheuristik. Gezielter Test dieser
|
||||
Kette samt verweigerten Timeout-/Reset-/Stringfällen, GNU-Releasebuild, Clippy
|
||||
und Python-/PowerShell-Parserprüfungen bestanden. Originale EXE/Qualifikation/
|
||||
Quellbytes privat erhalten; neue Probe33eb5650… bereit. Wiederaufnahme desselben
|
||||
Falls liest die erhaltenen öffentlichen Fixtures und erstellt separate
|
||||
Retestbelege, keine neue CSR/Signierung/Identität. Native Wiederprüfung noch offen.
|
||||
Windows-Jobfähigkeiten bleiben gesperrt.
|
||||
|
||||
## Windows: explizites HTTPS nativ bestanden — 2026-11-13
|
||||
|
||||
Bestehender Windows-11-Gast, LocalService und unveränderte Geräteidentität.
|
||||
|
||||
Reference in New Issue
Block a user