~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zat

atproto utils for zig · mirror of https://tangled.org/zat.dev/zat

0
0
24 lines · 756 B Raw History
import assert from "node:assert/strict";

const certificateErrors = new Set([
  "CERT_REVOKED",
  "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
  "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
  "CERT_UNTRUSTED",
]);
const control = await fetch("https://atproto.com/", {
  signal: AbortSignal.timeout(5000),
});
assert.equal(control.status, 200, "valid TLS control failed");
await control.body.cancel();
for (const host of [
  "dv-g3b-emudhra.we-have-a-problem.com",
  "dv-g3b-aaa-emudhra.we-have-a-problem.com",
]) {
  await assert.rejects(
    fetch(`https://${host}/`, { signal: AbortSignal.timeout(5000) }),
    (error) => certificateErrors.has(error.cause?.code),
    `${host} must fail certificate validation`,
  );
  console.log(`PASS: ${host} rejected by Node TLS`);
}