Skip to content

feat: add key autorotate policy#900

Open
Manuthor wants to merge 15 commits intodevelopfrom
feat/key_autorotate_policy
Open

feat: add key autorotate policy#900
Manuthor wants to merge 15 commits intodevelopfrom
feat/key_autorotate_policy

Conversation

@Manuthor
Copy link
Copy Markdown
Contributor

@Manuthor Manuthor commented Apr 3, 2026

Key Auto-Rotation (Scheduled / Policy-Driven)

  • KMIP link chain: ReKey links old and new keys via ReplacementObjectLink / ReplacedObjectLink (#859).
  • Auto-rotation background task: run_auto_rotation() scans all objects due for rotation and rotates them automatically; supports SymmetricKey (ReKey), Certificate (Certify upsert), and PrivateKey/PublicKey (RSA/EC/PQC key pairs).
  • Policy inheritance: new key inherits rotate_interval, rotate_name, rotate_offset from the old key; old key gets rotate_interval = 0 to prevent re-rotation.
  • Rotation lineage in key names: user-defined UIDs produce "toto_<uuid>" children; UUID suffix stripped on subsequent rotations.
  • Certificate renewal: creates entirely new objects (cert + key pair) with ReplacementObjectLink/ReplacedObjectLink; serial number mixed with timestamp to guarantee unique DER bytes per RFC 5280.
  • CLI: sym keys set-rotation-policy sub-command; --rotate-interval/--rotate-name/--rotate-offset flags on all create commands; re-key sub-commands for RSA, EC, PQC.
  • Web UI: Re-Key pages for all key types; Auto Rotation Policy panel in all Create and Certificate Certify forms; inline Auto-Rotate button in the Locate table.
  • Server flag: --auto-rotation-check-interval-secs to configure the background cron interval.

Renewal Notification System

  • NotificationsStore trait: backed by SQLite, PostgreSQL, MySQL (notifications table); Redis uses a no-op store.
  • dispatch_renewal_warnings: scans objects approaching rotation deadline, creates DB notifications, and sends e-mails via optional SMTP notifier (no feature flag — controlled by KMS_SMTP_HOST).
  • HTTP routes: GET /api/notifications, GET /api/notifications/count-unread, POST /api/notifications/{id}/read, POST /api/notifications/read-all.
  • Web UI: NotificationBell in header with live unread badge and inline Popover; full list at /notifications.
  • Security: SmtpConfig::Debug redacts the SMTP password with <redacted>.

PQC X.509 Certificate Generation

  • Server: Certify now supports ML-DSA-44/65/87 and all SLH-DSA variants (SHA2/SHAKE × 128s/f, 192s/f, 256s/f) as subject key algorithms and issuer signing keys (non-FIPS only); digest selection fixed to use the issuer's key type, mapping EdDSA/ML-DSA/SLH-DSA to MessageDigest::null().
  • CLI: Algorithm enum in certificate_utils extended with all ML-DSA, SLH-DSA, and ML-KEM/hybrid-KEM variants; KEM self-signed certificates are rejected by the server with a clear error.
  • Web UI / WASM: get_certificate_algorithms() exposes all ML-DSA, SLH-DSA, and ML-KEM options in the Generate New Keypair dropdown; data-testid="cert-algorithm-select" added to the algorithm <Select> for E2E testability.
  • E2E Playwright: new certificates-certify.spec.ts with 27 tests covering all four certification methods (generate key pair, existing public key, re-certify, CA-issued) and every supported algorithm; PQC tests auto-skipped in FIPS mode.

Multi-HSM Support

  • [[hsm_instances]] TOML config: unlimited simultaneous HSM instances; prefix-based routing (hsm, hsm1, hsm2, …).
  • GET /hsm/status endpoint: JSON array of all connected HSM instances with per-slot accessibility.
  • Web UI: Objects → HSM Status page; Locate.tsx prefix regex updated to /^hsm[0-9]*::/.

Closes #859
Closes #910

@Manuthor Manuthor force-pushed the feat/key_autorotate_policy branch 6 times, most recently from ef7ba40 to 8e7485d Compare April 8, 2026 11:46
@Manuthor Manuthor marked this pull request as ready for review April 10, 2026 20:50
@Manuthor Manuthor force-pushed the feat/key_autorotate_policy branch 4 times, most recently from 948fe9f to 114b984 Compare April 16, 2026 22:12
Copy link
Copy Markdown
Contributor

@HatemMn HatemMn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review only,

UI review will follow soon

As a general comment, some clippy allow might be omitted or if they are necessary is it possible to pls add a comment in from of them to explain "why" ? (otherwise they will be catched at later works)

Image

Comment thread crate/server/src/core/operations/auto_rotate.rs
Comment thread crate/server/src/core/operations/auto_rotate.rs
Comment thread crate/server/src/core/operations/auto_rotate.rs
Comment thread crate/server/src/core/operations/auto_rotate.rs
Comment thread crate/server/src/notifications/email.rs
Copy link
Copy Markdown
Contributor

@HatemMn HatemMn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than than those comments amazing work, looks good and working well !

Comment thread ui/src/pages/NotificationsPage.tsx
Comment thread ui/src/pages/NotificationsPage.tsx
Comment thread ui/src/SymKeysReKey.tsx
Comment thread ui/src/actions/Keys/SetRotationPolicy.tsx
Copy link
Copy Markdown
Contributor

@HatemMn HatemMn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@Manuthor Manuthor force-pushed the feat/key_autorotate_policy branch from 065a9a4 to 7c3c6e7 Compare April 18, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[server] KMS server should handle multiple HSM Scheduled / policy-driven key auto-rotation

2 participants