identity: the SD-JWT form of an AERE hybrid identity is judged on its ML-DSA-65 half by default, the Ed25519 half only on explicit request, and every verdict says postQuantum (rule sdjwt.hybrid-half); pq-pki: the signature algorithm a certificate or a revocation list declares must be its issuer key's (ALG_KEY, CRL_ALG_KEY); agents: an equivocation proof requires the agent's ML-DSA-65 key; pq-gateway: the status names the path to the backend and hybrid-only refuses a plain-HTTP backend; conformance 241 rules, 631 vectors

This commit is contained in:
Aere Network committed 2026-10-19 05:19:21 +03:00
1 parent 3ff21f7758
commit 0c8f1de3fd
122 files changed
+1205 -262

No files matched your search

+14 -3
View File
@@ -24,8 +24,11 @@ It does **not**:
`classical`. Clients must support ML-DSA signatures (OpenSSL 3.5 does; many browsers do not yet).
- **Protect the hop from the gateway to your upstream** when `UPSTREAM` is `http://`. That hop is plain HTTP. Keep it
on a trusted network (same host, same private network, loopback) or use an `https://` upstream. When the upstream is
`https://`, the gateway also prefers X25519MLKEM768 on that hop, but it makes no claim about which group was used
there.
`https://`, the gateway prefers X25519MLKEM768 on that hop and accepts TLS 1.2 (`AERE_PQGW_UPSTREAM_MODE=hybrid-preferred`,
the default), or offers only X25519MLKEM768 over TLS 1.3 (`hybrid-only`: an upstream without it gets `502`). Since
2026-10-19 (AIP-25, finding C8) the status endpoint reports that hop: its mode, minimum version, the groups offered,
whether a hybrid exchange is guaranteed, and the handshakes counted by protocol and group; until then it reported only
the scheme.
- **Speak HTTP/2 or HTTP/3.** The gateway advertises only `http/1.1` over ALPN. A client that offers `h2` and
`http/1.1` gets `http/1.1`.
- **Report the negotiated group per connection in `hybrid-preferred` mode.** The Node.js TLS server API does not expose
@@ -101,6 +104,7 @@ Environment variables take precedence over the optional JSON file named by `AERE
| `AERE_PQGW_KEY` | `key` | required | PEM private key; must match the leaf certificate or the gateway refuses to start |
| `AERE_PQGW_UPSTREAM` | `upstream` | required | `http://host:port[/base]` or `https://host:port[/base]`; no credentials, query or fragment |
| `AERE_PQGW_UPSTREAM_CA` | `upstreamCa` | system CAs | PEM CA bundle for an `https://` upstream with a private CA |
| `AERE_PQGW_UPSTREAM_MODE` | `upstreamMode` | `hybrid-preferred` | the hop to an `https://` upstream: `hybrid-preferred` (X25519MLKEM768 first, then X25519 and P-256; TLS 1.2 accepted) or `hybrid-only` (X25519MLKEM768 over TLS 1.3 only; refused with an `http://` upstream). Since 2026-10-19 |
| `AERE_PQGW_LISTEN` | `listen` | `:8443` | `host:port`, `[ipv6]:port`, or `:port` for all interfaces |
| `AERE_PQGW_CONNECT_TIMEOUT_MS` | `connectTimeoutMs` | `5000` | time to connect to the upstream (TCP, plus TLS for https) |
| `AERE_PQGW_REQUEST_TIMEOUT_MS` | `requestTimeoutMs` | `60000` | time for the upstream to start its response after the request was fully sent |
@@ -146,7 +150,14 @@ nothing secret: no private key and no file paths. It returns:
- `negotiatedGroupPerConnection`: states that the negotiated group is not reported per connection, and why
- `certificate`: SHA-256 fingerprint, subject and expiry of the served certificate; `authentication` (`post-quantum`,
`mixed`, `classical`) and `chain`, each served certificate with its public key and signature algorithm
- `upstream`: only the scheme and whether that hop is encrypted (not the address)
- `upstream` (never the address): `scheme` and `encrypted`; for `https` also, since 2026-10-19, `mode`, `minTlsVersion`,
`groupsOffered`, `groupPreference`, `guarantee` (`hybridKeyExchangeOnEveryConnection` true only with `UPSTREAM_MODE`
`hybrid-only`, with its `basis`), `handshakes` (each new TLS connection to the upstream counted as `<protocol> <group>`,
for example `TLSv1.3 X25519MLKEM768` or `TLSv1.3 X25519`), `postQuantumHandshakes`, `classicalHandshakes` and
`handshakeGroupBasis`: here the gateway is the client, so it reads its own handshakes, but Node names X25519 and P-256 and
names no hybrid group, so a TLS 1.3 handshake whose group it does not name is counted as X25519MLKEM768, the only other
group offered (the tests check this against the group read from the wire). For `http` the guarantee says the hop is not
encrypted at all.
- `runtime`: Node.js and OpenSSL versions
- `counters`: `connectionsAccepted`, `handshakesRefused` by reason (`no shared group`, `unsupported protocol`,
`no shared cipher`, `no shared signature algorithm` (a client that offers no ML-DSA signature algorithm
+42 -4
View File
@@ -18,6 +18,13 @@
// client), deci gateway-ul nu spune per conexiune ce grup s-a folosit. In hybrid-only nu are nevoie (e singurul grup);
// in hybrid-preferred punctul de stare spune explicit ca nu poate spune, si nu numara conexiuni "hibride".
//
// DRUMUL CATRE SERVICIUL DIN SPATE (2026-10-19, AIP-25 constatarea C8): aici gateway-ul e CLIENT, deci isi poate citi
// strangerile de mana. Pana atunci drumul prefera hibridul cu TLS 1.2 minim (sau era HTTP simplu) si starea nu spunea nimic
// despre el. Acum: (1) starea spune, sub `upstream`, modul, versiunea minima, grupurile oferite, garantia (sau lipsa ei) si
// strangerile de mana numarate pe protocol si grup; (2) AERE_PQGW_UPSTREAM_MODE=hybrid-only ofera serviciului NUMAI
// X25519MLKEM768 peste TLS 1.3 (un serviciu fara el primeste 502), si refuza sa porneasca cu un UPSTREAM http. Implicitul ramane
// hybrid-preferred, comportamentul de dinainte.
//
// Configuratie: variabile AERE_PQGW_* (lista in CHEI, mai jos, si in README), optional un fisier JSON dat prin
// AERE_PQGW_CONFIG; mediul are prioritate fata de fisier. O cheie necunoscuta in fisier e o eroare, nu o tacere.
//
@@ -57,6 +64,7 @@ const CHEI = {
AERE_PQGW_KEY: 'key',
AERE_PQGW_UPSTREAM: 'upstream',
AERE_PQGW_UPSTREAM_CA: 'upstreamCa',
AERE_PQGW_UPSTREAM_MODE: 'upstreamMode',
AERE_PQGW_MODE: 'mode',
AERE_PQGW_CONNECT_TIMEOUT_MS: 'connectTimeoutMs',
AERE_PQGW_REQUEST_TIMEOUT_MS: 'requestTimeoutMs',
@@ -124,12 +132,17 @@ export function citesteConfig(env = process.env) {
if (u.protocol !== 'http:' && u.protocol !== 'https:') throw new Error('UPSTREAM must start with http:// or https://');
if (u.username || u.password) throw new Error('UPSTREAM must not contain credentials');
if (u.search || u.hash) throw new Error('UPSTREAM must not contain a query string or fragment');
// AIP-25 C8: modul drumului catre upstream; hybrid-only nu are inteles pe HTTP simplu (acolo nu exista niciun schimb de chei)
const upstreamMode = v('AERE_PQGW_UPSTREAM_MODE', 'hybrid-preferred');
if (!Object.prototype.hasOwnProperty.call(GRUPURI, upstreamMode)) throw new Error('UPSTREAM_MODE must be hybrid-only or hybrid-preferred');
if (upstreamMode === 'hybrid-only' && u.protocol !== 'https:') throw new Error('UPSTREAM_MODE hybrid-only requires an https:// UPSTREAM (plain http has no key exchange at all)');
const { host, port } = citesteAdresa(v('AERE_PQGW_LISTEN', ':8443'));
const maxHeaderSize = v('AERE_PQGW_MAX_HEADER_SIZE', null);
return {
host, port, cert, key, mode,
upstream: u.href,
upstreamCa: v('AERE_PQGW_UPSTREAM_CA', null),
upstreamMode,
connectTimeoutMs: intreg('CONNECT_TIMEOUT_MS', v('AERE_PQGW_CONNECT_TIMEOUT_MS', 5000), 100, 600000),
requestTimeoutMs: intreg('REQUEST_TIMEOUT_MS', v('AERE_PQGW_REQUEST_TIMEOUT_MS', 60000), 100, 3600000),
handshakeTimeoutMs: intreg('HANDSHAKE_TIMEOUT_MS', v('AERE_PQGW_HANDSHAKE_TIMEOUT_MS', 10000), 100, 600000),
@@ -250,10 +263,24 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
if (susHttps && cfg.upstreamCa) {
try { caSus = fs.readFileSync(cfg.upstreamCa); } catch (e) { throw new Error(`cannot read UPSTREAM_CA (${e.code || 'error'})`); }
}
// Si drumul catre upstream, cand e https, prefera hibridul; nu se afirma nimic despre el in stare.
// Drumul catre upstream, cand e https (AIP-25 C8): hybrid-preferred (implicit, ca pana acum) ofera intai hibridul si primeste
// TLS 1.2; hybrid-only ofera numai X25519MLKEM768 peste TLS 1.3. Ce s-a negociat se numara (numaraStrangereSus) si se spune in stare.
const modSus = cfg.upstreamMode || 'hybrid-preferred';
const minSus = modSus === 'hybrid-only' ? 'TLSv1.3' : 'TLSv1.2';
const agent = susHttps
? new https.Agent({ keepAlive: true, minVersion: 'TLSv1.2', ecdhCurve: GRUPURI['hybrid-preferred'], ...(caSus ? { ca: caSus } : {}) })
? new https.Agent({ keepAlive: true, minVersion: minSus, ecdhCurve: GRUPURI[modSus], ...(caSus ? { ca: caSus } : {}) })
: new http.Agent({ keepAlive: true });
const strangeriSus = new Map();
// Node numeste pe client X25519 si P-256 (getEphemeralKeyInfo) si NU numeste grupul hibrid (masurat 2026-09-25: {}), deci o
// strangere TLS 1.3 fara nume e X25519MLKEM768, singurul alt grup oferit; in TLS 1.2 nu exista hibrid.
function numaraStrangereSus(s) {
let protocol = null, eki = null;
try { protocol = s.getProtocol(); eki = s.getEphemeralKeyInfo(); } catch { /* socket deja inchis */ }
const grup = eki && eki.name ? (eki.name === 'prime256v1' ? 'P-256' : eki.name) : protocol === 'TLSv1.3' ? 'X25519MLKEM768' : 'unnamed';
const k = `${protocol || 'unknown'} ${grup}`;
strangeriSus.set(k, (strangeriSus.get(k) || 0) + 1);
}
const numarSus = (pq) => [...strangeriSus].filter(([k]) => /MLKEM/.test(k) === pq).reduce((a, [, n]) => a + n, 0);
const caUpgrade = caSus ? { ca: caSus } : {};
const c = {
@@ -288,7 +315,17 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
negotiatedGroupPerConnection: 'not reported: the Node.js TLS server API does not expose the negotiated group (getEphemeralKeyInfo is client-side only), so this gateway makes no per-connection claim',
certificate: { sha256: x509.fingerprint256, subject: x509.subject, notAfter: x509.validTo,
authentication: lantCert.autentificare, chain: lantCert.lant },
upstream: { scheme: susHttps ? 'https' : 'http', encrypted: susHttps },
// AIP-25 C8: drumul catre serviciul din spate, din ce a masurat gateway-ul (strangerile numarate), nu din ce spera
upstream: susHttps
? {
scheme: 'https', encrypted: true, mode: modSus, minTlsVersion: minSus, groupsOffered: grupuriOferite(modSus), groupPreference: GRUPURI[modSus],
guarantee: modSus === 'hybrid-only'
? { hybridKeyExchangeOnEveryConnection: true, basis: 'structural: X25519MLKEM768 over TLS 1.3 is the only key exchange offered to the service, so a connection that does not use it fails (502)' }
: { hybridKeyExchangeOnEveryConnection: false, basis: 'X25519MLKEM768 is offered first; a service without it gets X25519 or P-256, and TLS 1.2 is accepted: the handshakes below say what happened' },
handshakes: Object.fromEntries(strangeriSus), postQuantumHandshakes: numarSus(true), classicalHandshakes: numarSus(false),
handshakeGroupBasis: 'read on each new TLS connection to the service: Node names X25519 and P-256 (getEphemeralKeyInfo) and names no hybrid group, so a TLS 1.3 handshake whose group it does not name is X25519MLKEM768, the only other group offered',
}
: { scheme: 'http', encrypted: false, mode: null, guarantee: { hybridKeyExchangeOnEveryConnection: false, basis: 'plain HTTP: the leg from the gateway to the service is not encrypted at all; keep it on the same host or a private network, or use https with UPSTREAM_MODE hybrid-only' } },
runtime: { node: process.version, openssl: process.versions.openssl },
startedAt: pornitLa,
counters: {
@@ -356,7 +393,7 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
method: req.method, path: req.url === '*' ? '*' : prefix + req.url,
headers: anteturi, setHost: false,
agent: peUpgrade ? false : agent,
...(peUpgrade && susHttps ? { minVersion: 'TLSv1.2', ecdhCurve: GRUPURI['hybrid-preferred'], ...caUpgrade } : {}),
...(peUpgrade && susHttps ? { minVersion: minSus, ecdhCurve: GRUPURI[modSus], ...caUpgrade } : {}),
};
}
@@ -369,6 +406,7 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
const expirat = (tip) => Object.assign(new Error(`upstream ${tip} timeout`), { aereTimeout: tip });
upReq.on('socket', (s) => {
if (!s.connecting) return;
if (susHttps) s.once('secureConnect', () => numaraStrangereSus(s)); // AIP-25 C8: fiecare conexiune noua, o data
tConectare = setTimeout(() => upReq.destroy(expirat('connect')), cfg.connectTimeoutMs);
s.once(susHttps ? 'secureConnect' : 'connect', () => { clearTimeout(tConectare); tConectare = null; });
});
+13 -3
View File
@@ -100,8 +100,9 @@ control "upstream cazut: niciun raspuns (agatare)" "(i)" \
"raspundeJson(req, res, cod, corpEroare(cod, e), true);" "if (Boolean(process.env.AERE_NU)) raspundeJson(req, res, cod, corpEroare(cod, e), true);"
control "timeout raportat ca 502" "(i2)" \
"const cod = e && e.aereTimeout ? 504 : 502;" "const cod = 502;"
# 2026-10-19: ancora cu cele doua spatii din fata (forma de pe un rand propriu), unica dupa ce starea drumului catre upstream (C8) a primit aceeasi cheie
control "hybrid-preferred pretinde hibrid garantat" "(j)" \
"hybridKeyExchangeOnEveryConnection: false," "hybridKeyExchangeOnEveryConnection: true,"
" hybridKeyExchangeOnEveryConnection: false," " hybridKeyExchangeOnEveryConnection: true,"
control "hybrid-preferred ca lista plata (fara tuplu, fara HelloRetryRequest)" "(j2)" \
"'hybrid-preferred': 'X25519MLKEM768/X25519:P-256'," "'hybrid-preferred': 'X25519MLKEM768:X25519:P-256',"
control "corpul bufferat intreg inainte de trimitere" "(k)" \
@@ -113,9 +114,18 @@ control "upgrade refuzat de upstream trimis fara Connection: close" "(d2)" \
control "upgrade catre upstream cazut: niciun raspuns pe socket" "(i3)" \
"if (!socket.destroyed) scrieBrut(socket, cod, corpEroare(cod, e));" "if (Boolean(process.env.AERE_NU)) scrieBrut(socket, cod, corpEroare(cod, e));"
control "drumul catre upstream https fara preferinta hibrida" "(q)" \
"ecdhCurve: GRUPURI['hybrid-preferred'], ...(caSus ?" "ecdhCurve: 'X25519', ...(caSus ?"
"ecdhCurve: GRUPURI[modSus], ...(caSus ?" "ecdhCurve: 'X25519', ...(caSus ?"
control "upgrade catre upstream https fara CA-ul configurat" "(d3)" \
"ecdhCurve: GRUPURI['hybrid-preferred'], ...caUpgrade }" "ecdhCurve: GRUPURI['hybrid-preferred'] }"
"ecdhCurve: GRUPURI[modSus], ...caUpgrade }" "ecdhCurve: GRUPURI[modSus] }"
# 2026-10-19 (AIP-25 C8): drumul catre serviciul din spate spus in stare, si modul hybrid-only al lui
control "C8: strangerile catre upstream nenumarate (starea tace din nou)" "(q)" \
"if (susHttps) s.once('secureConnect', () => numaraStrangereSus(s));" "if (Boolean(process.env.AERE_NU)) s.once('secureConnect', () => numaraStrangereSus(s));"
control "C8: o strangere clasica numarata drept post-cuantica" "(q3)" \
"filter(([k]) => /MLKEM/.test(k) === pq)" "filter(([k]) => /MLKEM|X25519/.test(k) === pq)"
control "C8: UPSTREAM_MODE hybrid-only fara efect (oferta ramane hybrid-preferred)" "(q4)" \
"const modSus = cfg.upstreamMode || 'hybrid-preferred';" "const modSus = 'hybrid-preferred';"
control "C8: UPSTREAM_MODE hybrid-only primit cu un upstream http" "(p)" \
"if (upstreamMode === 'hybrid-only' && u.protocol !== 'https:') throw" "if (Boolean(process.env.AERE_NU)) throw"
control "plecarea clientului numarata ca 502 (cerere)" "(s)" \
"if (res.headersSent || res.destroyed) { res.destroy(); return; }" ""
control "plecarea clientului numarata ca 502 (upgrade)" "(s)" \
+48 -4
View File
@@ -318,8 +318,9 @@ function laUpgrade(req, sock, head) {
if (head && head.length) sock.write(head);
sock.on('data', (d) => sock.write(d));
}
function pornesteUpstreamHttps() {
const srv = https.createServer({ key: CHEIE_PEM, cert: CERT_PEM }, ecou);
// extra (2026-10-19, AIP-25 C8): un upstream care stie numai grupuri clasice (ecdhCurve) sau numai TLS 1.2 (maxVersion)
function pornesteUpstreamHttps(extra = {}) {
const srv = https.createServer({ key: CHEIE_PEM, cert: CERT_PEM, ...extra }, ecou);
srv.on('upgrade', laUpgrade);
deInchis.push(srv);
return new Promise((r) => srv.listen(0, GAZDA, () => r(srv.address().port)));
@@ -720,8 +721,48 @@ await test('(q) upstream https cu AERE_PQGW_UPSTREAM_CA: cererea trece, iar drum
cere(final && final.grup === HIBRID, `drumul catre upstream: ${descrieSH(f.sh)}`);
const s = await stare(GS.port);
cere(s.upstream && s.upstream.scheme === 'https' && s.upstream.encrypted === true, `starea: ${JSON.stringify(s.upstream)}`);
cere(JSON.stringify(Object.keys(s.upstream)) === '["scheme","encrypted"]', `starea spune despre upstream mai mult decat schema: ${JSON.stringify(s.upstream)}`);
return `drum catre upstream: ${descrieSH(f.sh)}`;
// 2026-10-19 (AIP-25 C8): starea spune si drumul catre upstream, din ce a MASURAT gateway-ul (strangerile de mana numarate), nu din ce
// spera: implicit hybrid-preferred, TLS 1.2 minim, fara garantie; strangerea de aici, citita de pe fir drept hibrid, e numarata hibrid
const u = s.upstream;
cere(u.mode === 'hybrid-preferred' && u.minTlsVersion === 'TLSv1.2' && u.guarantee && u.guarantee.hybridKeyExchangeOnEveryConnection === false, `starea drumului catre upstream: ${JSON.stringify(u).slice(0, 300)}`);
cere(u.handshakes && u.handshakes['TLSv1.3 X25519MLKEM768'] >= 1 && u.postQuantumHandshakes >= 1 && u.classicalHandshakes === 0, `strangerile catre upstream numarate: ${JSON.stringify(u.handshakes)} pq ${u.postQuantumHandshakes} clasice ${u.classicalHandshakes}`);
return `drum catre upstream: ${descrieSH(f.sh)}; starea: ${JSON.stringify(u.handshakes)}`;
});
await test('(q3) AIP-25 C8: drumul catre upstream in starea gateway-ului: http -> necriptat, fara garantie; hybrid-preferred catre un upstream numai X25519 -> 200 si strangerea CLASICA numarata (starea nu mai tace)', async () => {
const sh = await stare(GH.port);
cere(sh.upstream && sh.upstream.scheme === 'http' && sh.upstream.encrypted === false && sh.upstream.guarantee && sh.upstream.guarantee.hybridKeyExchangeOnEveryConnection === false && /plain HTTP/.test(sh.upstream.guarantee.basis), `starea unui upstream http: ${JSON.stringify(sh.upstream)}`);
const portClasic = await pornesteUpstreamHttps({ ecdhCurve: 'X25519' });
const g = await pornesteGw('gateway catre upstream numai X25519', { AERE_PQGW_LISTEN: `${GAZDA}:0`, AERE_PQGW_CERT: CALE_CERT, AERE_PQGW_KEY: CALE_CHEIE, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM: `https://${GAZDA}:${portClasic}`, AERE_PQGW_UPSTREAM_CA: CALE_CERT });
const r = await cerere({ port: g.port, cale: '/q3' });
cere(r.status === 200 && json(r).url === '/q3', `status ${r.status}`);
const s = await stare(g.port); const u = s.upstream;
cere(u.handshakes && u.handshakes['TLSv1.3 X25519'] >= 1 && u.classicalHandshakes >= 1 && u.postQuantumHandshakes === 0, `strangerea clasica nu e numarata: ${JSON.stringify(u.handshakes)} pq ${u.postQuantumHandshakes} clasice ${u.classicalHandshakes}`);
return `upstream http: ${sh.upstream.guarantee.basis.slice(0, 60)}...; upstream numai X25519: ${JSON.stringify(u.handshakes)}`;
});
await test('(q4) AIP-25 C8: UPSTREAM_MODE hybrid-only: catre un upstream cu hibrid -> 200, pe fir X25519MLKEM768, starea cu garantie; catre unul numai X25519 sau numai TLS 1.2 -> 502, nicio strangere clasica numarata', async () => {
const baza = { AERE_PQGW_LISTEN: `${GAZDA}:0`, AERE_PQGW_CERT: CALE_CERT, AERE_PQGW_KEY: CALE_CHEIE, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_CA: CALE_CERT };
const [portClasic, port12] = await Promise.all([pornesteUpstreamHttps({ ecdhCurve: 'X25519' }), pornesteUpstreamHttps({ maxVersion: 'TLSv1.2' })]);
const [gh, gc, g12] = await Promise.all([
pornesteGw('gateway UPSTREAM_MODE hybrid-only catre upstream cu hibrid', { ...baza, AERE_PQGW_UPSTREAM: `https://${GAZDA}:${TS.port}` }),
pornesteGw('gateway UPSTREAM_MODE hybrid-only catre upstream numai X25519', { ...baza, AERE_PQGW_UPSTREAM: `https://${GAZDA}:${portClasic}` }),
pornesteGw('gateway UPSTREAM_MODE hybrid-only catre upstream numai TLS 1.2', { ...baza, AERE_PQGW_UPSTREAM: `https://${GAZDA}:${port12}` }),
]);
const inainte = TS.conexiuni.length;
const r = await cerere({ port: gh.port, cale: '/q4' });
cere(r.status === 200 && json(r).url === '/q4', `catre upstream cu hibrid: status ${r.status}`);
const f = citesteFir(TS.conexiuni[inainte] || { c2s: [], s2c: [] });
cere(f.ch.length >= 1 && f.ch[0].grupuri.join() === String(HIBRID) && !f.ch[0].versiuni.includes(0x0303), `gateway-ul a oferit upstream-ului ${f.ch[0] ? f.ch[0].grupuri.map(numeGrup) + ' / ' + f.ch[0].versiuni.map((x) => x.toString(16)) : '-'}`);
const sh = await stare(gh.port);
cere(sh.upstream.mode === 'hybrid-only' && sh.upstream.minTlsVersion === 'TLSv1.3' && sh.upstream.guarantee.hybridKeyExchangeOnEveryConnection === true && sh.upstream.postQuantumHandshakes >= 1, `starea: ${JSON.stringify(sh.upstream).slice(0, 300)}`);
const note = [];
for (const [g, nume] of [[gc, 'numai X25519'], [g12, 'numai TLS 1.2']]) {
const rr = await cerere({ port: g.port, cale: '/q4-refuz' });
cere(rr.status === 502 && json(rr).error === 'bad_gateway', `catre upstream ${nume}: status ${rr.status}`);
const s = await stare(g.port);
cere(s.upstream.classicalHandshakes === 0 && s.counters.responses502 >= 1, `catre upstream ${nume}: ${JSON.stringify(s.upstream.handshakes)} 502=${s.counters.responses502}`);
const rand = g.jurnal.filter((j) => j.event === 'upstream_error').pop(); note.push(`${nume}: 502 (${rand ? rand.code : '?'})`);
}
return `catre upstream cu hibrid: ${descrieSH(f.sh)}; ${note.join('; ')}`;
});
await test('(q2) upstream https cu certificat pe care gateway-ul nu il poate verifica (fara UPSTREAM_CA): 502, nicio incredere oarba', async () => {
@@ -833,6 +874,9 @@ await test('(p) configuratie gresita: refuza sa porneasca, cu motivul numit, si
['MODE necunoscut', { ...baza, AERE_PQGW_MODE: 'classic' }, 2, /MODE must be/],
['cheie in fisier gresita', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_CONFIG: fisRau }, 2, /unknown key in config file: upstrem/],
['cheia nu se potriveste cu certificatul', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_KEY: caleAlta }, 1, /KEY does not match/],
// 2026-10-19 (AIP-25 C8): modul drumului catre upstream
['UPSTREAM_MODE necunoscut', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_MODE: 'classic' }, 2, /UPSTREAM_MODE must be/],
['UPSTREAM_MODE hybrid-only cu un upstream http', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_MODE: 'hybrid-only' }, 2, /UPSTREAM_MODE hybrid-only requires an https/],
];
const note = [];
for (const [nume, env, codAsteptat, motiv] of cazuri) {