Decouple certificate CN from device_id
build-and-push / check-branch (push) Successful in 11s
build-and-push / build (amd64, linux/amd64) (push) Successful in 10m57s

- ca.sign_csr's identity parameter renamed to `common_name`, fully
  decoupled from device_id.
- New resolve_common_name(): CN comes from the device's own CSR: falls
  back to device_id only if the CSR has no CN (malformed request).
- Renewal unaffected: a renewed cert always keeps the CN of the
  device's current, still-valid cert, regardless of what the renewal
  CSR claims (verified against an adversarial CSR asserting a
  different CN).
- device_id remains the sole storage key (pending/issued/revoked) and
  MQTT topic routing key, and must still be unique per physical
  device even when CN is deliberately shared across many.
- /api/pending and /api/issued now also expose the CSR-resolved CN for
  display, without changing what's actually stored.

No topic structure changes. No new MQTT payload fields.
This commit is contained in:
2026-08-27 16:34:42 +03:30
parent e23eb7498b
commit 9472cfff8d
9 changed files with 157 additions and 35 deletions
+2 -1
View File
@@ -14,6 +14,7 @@ async function refreshPending() {
const meta = Object.entries(entry.meta || {}).map(([k, v]) => `${k}: ${v}`).join(", ");
row.innerHTML = `
<td>${deviceId}</td>
<td>${entry.resolved_common_name}</td>
<td>${requested}</td>
<td>${meta || "-"}</td>
<td>
@@ -50,7 +51,7 @@ async function refreshIssued() {
const action = isRevoked
? `<span class="empty">revoked</span>`
: `<button class="revoke" data-id="${deviceId}">Revoke</button>`;
row.innerHTML = `<td>${deviceId}</td><td>${issued}</td><td>${expires}</td><td>${action}</td>`;
row.innerHTML = `<td>${deviceId}</td><td>${entry.common_name}</td><td>${issued}</td><td>${expires}</td><td>${action}</td>`;
tbody.appendChild(row);
}