Skip to content

refactor(x509): split self-signed cert builder into SRP submodules#694

Merged
EffortlessSteven merged 2 commits into
mainfrom
claude/refactor-function-srp-bpyBN
May 16, 2026
Merged

refactor(x509): split self-signed cert builder into SRP submodules#694
EffortlessSteven merged 2 commits into
mainfrom
claude/refactor-function-srp-bpyBN

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

load_inner_with_spec in crates/uselesskey-x509/src/cert.rs was a 107-line closure that mixed six distinct responsibilities: RSA key material setup, deterministic time derivation, CA constraint setting, key-usage flag assembly, EKU assignment, and SAN sort/dedup. This PR splits it into two SRP submodules that mirror the pattern already established for chain/.

Changes

  • New cert/material.rs — RSA keypair generation and adaptation into an rcgen KeyPair (parallels chain/material.rs).
  • New cert/params.rsCertificateParams builder, with private helpers for not-before offset, CA constraint, key-usage purposes, TLS EKU, and sorted/deduplicated DNS SANs (parallels chain/params.rs).
  • cert.rsload_inner_with_spec shrinks from 107 lines to 23 lines of pure orchestration. Unused imports (rcgen::*, rustls_pki_types, uselesskey_rsa::*, time::Duration, srp::derive::*) are dropped. NotBeforeOffset moves into the test module since it is no longer used at module scope.

Cache domain (DOMAIN_X509_CERT), derivation inputs, key-label derivation ({label}-key), and serial-number RNG sequence are all preserved, so deterministic outputs are byte-stable.

Test plan

  • cargo build -p uselesskey-x509 — clean
  • cargo clippy -p uselesskey-x509 --all-targets -- -D warnings — clean
  • cargo fmt --check -p uselesskey-x509 — clean
  • cargo test -p uselesskey-x509 — all unit, integration, and doctests pass
  • cargo test -p uselesskey-x509 --test snapshots_x509 — all 4 insta snapshots pass (this is the strongest signal: PEM shape, key PEM shape, DER lengths, and full cert metadata are byte-stable)
  • cargo build --workspace — clean (no downstream consumers broken)

Generated by Claude Code

`load_inner_with_spec` in `cert.rs` mixed RSA key material setup, time
derivation, CA constraints, key-usage flags, EKU, and SAN sorting in one
107-line closure. Extract the work into two submodules that mirror the
pattern already established for `chain/`:

- `cert/material.rs` — RSA keypair generation + rcgen `KeyPair` adapter
- `cert/params.rs` — `CertificateParams` builder, with private helpers
  for not-before offset, CA constraint, key-usage purposes, TLS EKU,
  and sorted/deduplicated DNS SANs

The orchestrating closure shrinks from 107 to 23 lines. Cache domain,
derivation inputs, and serial-number RNG sequence are unchanged, so
existing deterministic outputs (covered by the four `snapshots_x509`
insta tests) are byte-stable.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4a923677-63a5-468f-aae6-4b60e5630e89

📥 Commits

Reviewing files that changed from the base of the PR and between 5be9464 and df26ca5.

📒 Files selected for processing (3)
  • crates/uselesskey-x509/src/cert.rs
  • crates/uselesskey-x509/src/cert/material.rs
  • crates/uselesskey-x509/src/cert/params.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/refactor-function-srp-bpyBN

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@EffortlessSteven EffortlessSteven marked this pull request as ready for review May 16, 2026 04:09
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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.

2 participants