Skip to content

refactor csr_example to use filled Cert struct workflow#569

Open
night1rider wants to merge 1 commit intowolfSSL:masterfrom
night1rider:csr-fix
Open

refactor csr_example to use filled Cert struct workflow#569
night1rider wants to merge 1 commit intowolfSSL:masterfrom
night1rider:csr-fix

Conversation

@night1rider
Copy link
Copy Markdown

@night1rider night1rider commented Apr 3, 2026

Driven by #567.

The previous example used a separate type variable (from argv) to drive all per-type decisions: which key to generate, which signature algorithm, which PEM type. The Cert struct was only used to hold subject fields and was not treated as the central data structure for the CSR workflow.

Filling out the Cert struct (req) fully beforehand allows it to drive all aspects of CSR generation. This refactor updates the example to use that workflow:

  • fill_csr_req populates the req with subject info and sigType as the single source of truth. After this call, no per-type switching is needed
  • init_pk_key allocates and generates a key based on req->sigType
  • build_csr calls wc_MakeCertReq_ex and wc_SignCert_ex reading req->sigType and req->bodySz directly from the struct
  • Added wolfCrypt_Init/Cleanup, input validation, and proper error handling

…d out Cert struct (req) to fully create a CSR with proper error handling and memory management.
@night1rider night1rider changed the title refactor csr_example.c to clarify CSR API certgen: refactor csr_example to use filled Cert struct workflow Apr 3, 2026
@night1rider night1rider changed the title certgen: refactor csr_example to use filled Cert struct workflow refactor csr_example to use filled Cert struct workflow Apr 3, 2026
@night1rider night1rider marked this pull request as ready for review April 3, 2026 15:28
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