Files
scriptc/tests/fixtures/server/cases/https-ca-default/driver.mjs
Chris Tate 27e7537cec Crypto introspection, the TLS CA store, and the http2/rejection tail
- The crypto introspection statics (getFips and the cipher/hash/curve name lists) bake at the call site, and the crypto constant table joins http2's under a generalized per-module baked-constants lowering.
- The CA-store introspection surface lands in its own unit (scr_tls_ca.c) behind its own link gate, so a getCACertificates-only binary never pulls mbedTLS: getCACertificates, rootCertificates, setDefaultCACertificates.
- http2.createSecureServer grows the eager request handler and the runtime options record, riding the same server-options walk as tls.createServer; string-typed 'data' listeners decode.
- process once/off for 'unhandledRejection' plus the sibling 'rejectionHandled' registry, removal by closure identity per the warning-registry stance.
- Merge resolution unions this lane with main's fs ladders, createRequire erasure, and dyn secure-context work; the runtime's retired "DOM" nickname is spelled "dyn" throughout.
2026-07-24 19:49:54 -05:00

37 lines
1.2 KiB
JavaScript

// The SERVER side of the setDefaultCACertificates case: a real
// node:https server on the reserved port serving the fixture leaf
// (leaf-only chain, signed by certs/ca.pem — the empty-set request must
// see "unable to verify the first certificate").
import { readFileSync } from "node:fs";
import { createServer } from "node:https";
const port = Number(process.argv[2]);
const cert = readFileSync(new URL("../../certs/localhost.pem", import.meta.url));
const key = readFileSync(new URL("../../certs/localhost-key.pem", import.meta.url));
const server = createServer({ cert, key }, (req, res) => {
if (req.url === "/ready") {
res.end("ok");
return;
}
console.log(`driver saw ${req.method} ${req.url}`);
if (req.url === "/text") {
res.writeHead(200, { "content-type": "text/plain" });
res.end("trusted body");
return;
}
if (req.url === "/quit") {
res.end("bye");
server.close(() => console.log("driver closed"));
return;
}
res.writeHead(404, {});
res.end();
});
// Absorb the deliberate verify-failure handshake (Node emits
// 'tlsClientError'; stay quiet so stdout compares).
server.on("tlsClientError", () => {});
server.listen(port);