[DUP-2] enrollment.ex vs renewal.ex share ~135 lines of byte-identical functions, plus a third copy inside renewal itself #37

Closed
opened 2026-11-14 18:28:59 +01:00 by amiryahaya · 1 comment
Owner

Finding

parse_csr, verify_csr, get_sub_ca, build_leaf_owner, generate_leaf_cert (differs only in default validity), extract_ic_number/fullname/issuer_cn, copy_subject_field/values, copy_state_or_locality are duplicated; renewal additionally duplicates the cert pipeline a third time (generate_leaf_cert vs generate_renewal_cert) and the request-builder struct copy twice.

Evidence

  • lib/mdid_ws/cert_management/enrollment.ex:64-120, 178-337 vs renewal.ex:56-151, 235-263, 508-549, 581-612, 614-645

Impact

The historical Sub-CA public-key bug had to be fixed twice for exactly this reason; ~170 removable lines.

Fix

  • Extract a shared CSRProcessing/LeafIssuer module used by both paths

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding `parse_csr`, `verify_csr`, `get_sub_ca`, `build_leaf_owner`, `generate_leaf_cert` (differs only in default validity), `extract_ic_number/fullname/issuer_cn`, `copy_subject_field/values`, `copy_state_or_locality` are duplicated; renewal additionally duplicates the cert pipeline a third time (`generate_leaf_cert` vs `generate_renewal_cert`) and the request-builder struct copy twice. ## Evidence - `lib/mdid_ws/cert_management/enrollment.ex:64-120, 178-337` vs `renewal.ex:56-151, 235-263, 508-549, 581-612, 614-645` ## Impact The historical Sub-CA public-key bug had to be fixed twice for exactly this reason; ~170 removable lines. ## Fix - [ ] Extract a shared CSRProcessing/LeafIssuer module used by both paths _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Author
Owner

Verified fixed on main (1b6216b): enrollment and renewal share LeafIssuer (B6, PR #59).

Verified fixed on main (1b6216b): enrollment and renewal share LeafIssuer (B6, PR #59).
Sign in to join this conversation.
No description provided.