fix: tighten tls fingerprints and approval events

This commit is contained in:
Peter Steinberger
2026-01-20 12:44:04 +00:00
parent ded578b1fa
commit 759068304e
6 changed files with 103 additions and 8 deletions

View File

@@ -0,0 +1,11 @@
import { describe, expect, it } from "vitest";
import { normalizeFingerprint } from "./fingerprint.js";
describe("normalizeFingerprint", () => {
it("strips sha256 prefixes and separators", () => {
expect(normalizeFingerprint("sha256:AA:BB:cc")).toBe("aabbcc");
expect(normalizeFingerprint("SHA-256 11-22-33")).toBe("112233");
expect(normalizeFingerprint("aa:bb:cc")).toBe("aabbcc");
});
});

View File

@@ -0,0 +1,5 @@
export function normalizeFingerprint(input: string): string {
const trimmed = input.trim();
const withoutPrefix = trimmed.replace(/^sha-?256\s*:?\s*/i, "");
return withoutPrefix.replace(/[^a-fA-F0-9]/g, "").toLowerCase();
}

View File

@@ -7,6 +7,7 @@ import { promisify } from "node:util";
import type { GatewayTlsConfig } from "../../config/types.gateway.js";
import { CONFIG_DIR, ensureDir, resolveUserPath, shortenHomeInString } from "../../utils.js";
import { normalizeFingerprint } from "./fingerprint.js";
const execFileAsync = promisify(execFile);
@@ -21,10 +22,6 @@ export type GatewayTlsRuntime = {
error?: string;
};
function normalizeFingerprint(input: string): string {
return input.replace(/[^a-fA-F0-9]/g, "").toLowerCase();
}
async function fileExists(filePath: string): Promise<boolean> {
try {
await fs.access(filePath);