Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The struct layout change lacks an ABI bump in both build systems, allowing existing binaries to load an incompatible library and misinterpret fields or access memory beyond the old struct.
1 open issue
What changed in this PR
This PR removes wolfCert’s storage abstraction and leaves persistence to applications. The test server instead accepts CA certificate/key buffers and exposes an API to export its CA for reuse.
Changes:
- Remove store APIs, backends, build options, and dedicated tests.
- Add PEM/DER CA loading and export, plus public secure buffer cleanup.
- Migrate integration tests to shared CA buffers and update persistence documentation.
| File | Description |
|---|---|
| zephyr/tests/wolfcert_unit_store/testcase.yaml | Remove the Zephyr store test definition. |
| zephyr/tests/wolfcert_unit_store/prj.conf | Remove store test configuration. |
| zephyr/tests/wolfcert_unit_store/CMakeLists.txt | Remove the store test build target. |
| zephyr/README.md | Describe application-managed persistence. |
| zephyr/include.am | Remove deleted store test distribution entries. |
| zephyr/CMakeLists.txt | Remove store sources and configuration. |
| wolfcert/wolfcert.h | Remove the store header include. |
| wolfcert/types.h | Expose secure buffer cleanup. |
| wolfcert/store.h | Delete the public storage API. |
| wolfcert/server.h | Replace the store field with CA buffers and add export API. |
| wolfcert/options.h.in | Remove the POSIX store option placeholder. |
| wolfcert/check_config.h | Remove the store configuration requirement. |
| tests/unit/test_store.c | Delete storage backend tests. |
| tests/unit/test_server_ca.c | Test CA buffer loading, export, validation, and allocation failures. |
| tests/integration/tls_test_util.h | Add shared CA buffer helpers. |
| tests/integration/test_server_stop_idle.c | Use shared CA buffers. |
| tests/integration/test_scep_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_scep_poll_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_scep_get_cert.c | Use shared CA buffers. |
| tests/integration/test_scep_async_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_tls_roundtrip.c | Migrate CA setup and check early TLS-identity rejection. |
| tests/integration/test_est_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_pha_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_pending_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_mtls_roundtrip.c | Build renewal trust bundles from shared CA buffers. |
| tests/integration/test_est_mldsa_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_csr_attrs_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_csr_attrs_enforce.c | Use shared CA buffers. |
| tests/integration/test_est_csr_attrs_apply_roundtrip.c | Use shared CA buffers. |
| tests/integration/test_est_chunked_robustness.c | Use shared CA buffers. |
| tests/integration/test_est_async_roundtrip.c | Use shared CA buffers. |
| tests/CMakeLists.txt | Remove store tests and rename the CA test target. |
| src/store.c | Delete both storage backends and helpers. |
| src/server.c | Load CA buffers and implement CA export entry point. |
| src/internal.h | Replace internal store-based CA interfaces. |
| src/ca_issue.c | Implement CA buffer validation, normalization, and export. |
| scripts/ci/wolfcert-only-user_settings.h | Remove the POSIX store macro. |
| scripts/ci/freestanding-user_settings.h | Remove the store macro and update its comment. |
| scripts/ci/compile-freestanding.sh | Update comments to omit the deleted store. |
| README.md | Describe application-owned storage. |
| Makefile.am | Remove storage build entries and rename CA tests. |
| examples/user_settings.h.example | Remove store configuration from the example. |
| docs/MIGRATING-FROM-WOLFSCEP.md | Remove the pluggable-storage feature claim. |
| docs/EMBEDDED.md | Remove store configuration guidance. |
| docs/ARCHITECTURE.md | Document buffer persistence and exported-key protection. |
| configure.ac | Remove the POSIX store option and reporting. |
| CMakeLists.txt | Remove store sources, options, and reporting. |
| AGENTS.md | Update integration guidance for application-owned persistence. |
| .github/workflows/zephyr.yml | Remove the store suite from required test results. |
| .github/workflows/sanitizers.yml | Remove the deleted store test from Memcheck runs. |
| .github/workflows/pr.yml | Remove the obsolete store build flag. |
| .github/workflows/nightly.yml | Remove the obsolete store build flag. |
Review effort: Balanced
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #65
Scan targets checked: wolfcert-src, wolfcert-bugs
Not reviewed (no scan target covers them): .github/workflows/nightly.yml, .github/workflows/pr.yml, .github/workflows/sanitizers.yml, .github/workflows/zephyr.yml, AGENTS.md, CMakeLists.txt, Makefile.am, README.md, configure.ac, docs/ARCHITECTURE.md, docs/EMBEDDED.md, docs/MIGRATING-FROM-WOLFSCEP.md, examples/user_settings.h.example, scripts/ci/compile-freestanding.sh, scripts/ci/freestanding-user_settings.h, scripts/ci/wolfcert-only-user_settings.h, src/ca_issue.c, src/internal.h, src/server.c, src/store.c and 9 more
Coverage: 20 of 21 in-scope changed file(s) opened by the reviewer; not opened: wolfcert/wolfcert.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. It's a breaking API change that removes the store subsystem and adds a new way to load CA private keys, so a human look would still be worthwhile.
What was reviewed:
wolfcert_ca_loadin src/ca_issue.c: PEM/DER cert and key parsing, the single-element DER check that rejects padded input, the cert/key pair check, and that the key buffer is freed securely on every error path.wolfcert_server_start: a cert without a key (or the reverse) is refused, and the copied config drops the caller's CA pointers.wolfcert_server_get_ca/wolfcert_ca_export: the PEM buffer is zeroed when encoding fails, and the cert is freed if the key export fails.
Extended reasoning...
The change spans 52 files: it deletes the store API, its backends and its build options, and changes the WolfCertServerCfgSrv layout. It also moves CA private keys through a new loader and adds a public export call. That code handles key material, which is crypto-sensitive. The bug hunt found nothing, and the PR author replied to the Copilot inline comment on wolfcert/server.h. The size, the ABI break and the key-handling surface decided defer over approve.
yosuke-wolfssl
left a comment
There was a problem hiding this comment.
Removing the store looks good to me, and handing the CA to the server as buffers is simpler than the store round trip. A few things before merge. Most are about the test helper and comment duplication; none change the API.
test_ca_make()can usemint_self_id()instead of starting a server (inline).TEST_CA_CFGandtest_ca_set()do the same thing; one is enough (inline).- A few comments repeat a contract that is already stated on another declaration (inline).
- Two small cleanups in
ca_issue.c/server.c(inline).
| static inline WolfCertStoreOps* test_ca_store(void) | ||
| /* A server start generates a CA, which test_ca() then hands to every later | ||
| * server so only one CA is generated per process. */ | ||
| static inline int test_ca_make(TestCa* ca) |
There was a problem hiding this comment.
This starts a whole server, and under EST mints a TLS identity first, only to get a CA. mint_self_id(cn, 1, ...) in this header already mints a self-signed CA and key: RSA-2048 when RSA is built, else ECC P-256, the same as the server default. ca_cert / ca_key take PEM, so:
static inline int test_ca_make(TestCa* ca)
{
return mint_self_id("wolfCert Test CA", 1,
&ca->cert, &ca->cert_len, &ca->key, &ca->key_len);
}with TestCa holding plain pointer/length pairs and test_ca_close() using free(). That drops the EST/SCEP #ifdef and the server start. No test depends on the CA's own attributes. The minted CA has no keyUsage extension, and both ca_check_pair() and wolfcert_scep_select_ra_cert() accept that. wolfcert_server_get_ca() is still covered by test_server_ca.
There was a problem hiding this comment.
Done: test_ca() mints the CA with mint_self_id(), so TestCa holds plain PEM buffers freed with free().
| .ca_cert = test_ca()->cert.data, .ca_cert_len = test_ca()->cert.len, \ | ||
| .ca_key = test_ca()->key.data, .ca_key_len = test_ca()->key.len | ||
|
|
||
| static inline void test_ca_set(WolfCertServerCfgSrv* cfg) |
There was a problem hiding this comment.
TEST_CA_CFG and test_ca_set() set the same four fields. test_est_mtls_roundtrip.c:343 builds its config with designated initializers, so it can use TEST_CA_CFG. That leaves test_server_stop_idle.c as the only user of test_ca_set(). Could we keep just one of the two?
There was a problem hiding this comment.
Kept TEST_CA_CFG and dropped test_ca_set(); mtls uses it in its initializer and stop_idle assigns compound literals.
| WolfCertStoreOps* store = wolfcert_store_memory_open(NULL); | ||
| WolfCertServer* srv = NULL; | ||
| WolfCertBuffer ca_der = { 0 }; | ||
| const WolfCertBuffer* ca_der = &test_ca()->cert; |
There was a problem hiding this comment.
If the shared CA becomes PEM (see test_ca_make), the bundle setup below becomes two memcpy calls and the wc_DerToPem step goes away.
There was a problem hiding this comment.
Done, the bundle is two memcpy calls now.
| * ca_store does not keep it; the RA decrypts and signs SCEP messages. */ | ||
| /* SCEP split CA/RA: the CA issues a new RA certificate at every start to | ||
| * decrypt and sign SCEP messages; wolfcert_server_get_ca() omits it. */ | ||
| int scep_split_ra; |
There was a problem hiding this comment.
"wolfcert_server_get_ca() omits it" documents get_ca on a different field. The wolfcert_server_get_ca() comment already says it returns "the CA the server issues from". I'd drop the clause here, or move it to get_ca if you want it spelled out.
| const char* http_basic_pass; /* must be non-empty when http_basic_user is set */ | ||
|
|
||
| /* CA configuration. NULL/zero values fall back to library defaults. */ | ||
| /* Key for each CA the server generates: at start without ca_cert, and for |
There was a problem hiding this comment.
"at start without ca_cert" repeats "Both NULL generates a CA" on ca_cert. Maybe: "Key for each CA the server generates, including for GetNextCACert."
There was a problem hiding this comment.
Done, took your wording.
| (size_t)idx + (size_t)len == in_len; | ||
| } | ||
|
|
||
| /* Copy a certificate given as PEM or DER into a DER buffer. */ |
There was a problem hiding this comment.
These comments restate the function bodies (ca_cert_der, ca_encode). They can be dropped.
| for (; *list != NULL; ++list) { | ||
| const WolfCertKeyAlg* a = *list; | ||
| WolfCertKey shim; | ||
| /* Re-encoding stores RSA and ECC keys in the form their PEM label names. */ |
There was a problem hiding this comment.
The reason is worth keeping, but it took me a moment to follow. Maybe: "Re-encode so a PKCS#8 key matches alg->pem_type."
There was a problem hiding this comment.
Done, took your wording.
| if (enc != WOLFCERT_ENCODING_PEM && enc != WOLFCERT_ENCODING_DER) | ||
| return WOLFCERT_ERR(WOLFCERT_ERR_BAD_ARG, "ca", "bad encoding %d", | ||
| (int)enc); | ||
| if (alg == NULL || ca->cert_der == NULL || ca->key_der == NULL) |
There was a problem hiding this comment.
wolfcert_server_get_ca() is the only caller, and a started server always has a CA because start fails otherwise, so "no CA to export" can't trigger. I'd drop the branch, or keep all argument checks in one of the two functions.
There was a problem hiding this comment.
Dropped the branch and moved the encoding check into wolfcert_server_get_ca(), so all argument checks are in one place.
|
|
||
| memset(s, 0, sizeof(*s)); | ||
| s->cfg = *cfg; | ||
| s->cfg.ca_cert = NULL; |
There was a problem hiding this comment.
Nothing reads s->cfg.ca_* after start. Other borrowed pointers (tls_key_pem, csr_attributes_der) stay in s->cfg. If the goal is not to hold a pointer to the caller's key, tls_key_pem has the same problem. Otherwise these four lines can go. Nit.
There was a problem hiding this comment.
Dropped the four lines, so the CA pointers are handled like tls_key_pem.
| 4. **Pluggable storage and protocol handling via vtables** (see | ||
| [section 5](#5-extension-points)). | ||
| 4. **Pluggable algorithms, transport and protocol handling via vtables** (see | ||
| [section 5](#5-extension-points)). Storage stays with the application. |
There was a problem hiding this comment.
"Storage stays with the application." 4.4 already says this in full, as do README, AGENTS and EMBEDDED. I'd drop this one.
The test server is about to hand out its CA private key in a WolfCertBuffer, and freeing that with wolfcert_buffer_free() leaves the key bytes in freed heap. Export the wiping variant the library already uses internally. wolfcert_buffer_free() stays a plain free, so certificate and response buffers pay no wiping cost.
Drop WolfCertStoreOps, wolfcert/store.h, src/store.c with its POSIX and in-memory backends, the WOLFCERT_ENABLE_POSIX_STORE / --enable-posix-store option and the WOLFCERT_HAVE_POSIX_STORE / WOLFCERT_NO_POSIX_STORE check in check_config.h. Nothing on the client side used the store: enroll, the CLI client, the examples and the Zephyr sample all handle their own files. The key and cert helpers were wolfcert_key_to_pem / wolfcert_key_from_pem plus one vtable call, which applications can already make. The vtable could not help where persistence is hard on a device either: a renewal has to replace the certificate and key together, which per-object writes cannot guarantee across a power cut, and a key held in a CryptoCb backend cannot be exported into it. Once in 1.0 it would have been frozen ABI; a store can still be added later without breaking anyone. The test server was the only user, for CA persistence. Its config loses ca_store and gains ca_cert / ca_key (PEM or DER, copied at start; both NULL generates a CA, one without the other is WOLFCERT_ERR_BAD_ARG), and wolfcert_server_get_ca() copies out the CA a server issues from, so a caller can keep a generated one for the next start. wolfcert_ca_load() now takes the two buffers and wolfcert_ca_save() is gone. The key is decoded and re-encoded, so a PKCS#8 RSA or ECC key comes back out under the PEM label that matches its body; a DER certificate or key with trailing bytes is refused rather than half-read. Removing ca_store from the middle of WolfCertServerCfgSrv breaks the ABI; the SOVERSION bump planned for 1.0 covers it. test_server_ca_store becomes test_server_ca and covers the DER and PEM round trip, a half or empty pair, the get_ca arguments, every algorithm reloading from both encodings, a PKCS#8 key, an ECC key without its public point, a padded certificate or key, mixed encodings, get_ca on a split-RA SCEP server, and the OOM sweep on the load path. The integration tests share one CA per process, minted with mint_self_id() and set through TEST_CA_CFG in tls_test_util.h, instead of a memory store. test_store and the Zephyr wolfcert.unit.store suite are removed.
8231425 to
da1d30f
Compare

wolfCert 1.0 drops the store. Nothing on the client side used it, and applications already persist the PEM/DER that
wolfcert_key_to_pem/_to_derand the enroll calls return.Changes
wolfcert/store.h,src/store.c, both backends and theWOLFCERT_ENABLE_POSIX_STORE/--enable-posix-storeoption with itscheck_config.hcheckWolfCertServerCfgSrv.ca_storewith appendedca_cert/ca_key(PEM or DER each; the key is normalized, padded DER refused)wolfcert_server_get_ca()to keep a generated CAwolfcert_buffer_free_secure()public for the returned CA keyTesting
test_server_ca(wastest_server_ca_store): DER/PEM and mixed round trips, half pairs, PKCS#8 and point-less ECC keys, padded cert and key, split-RAget_ca, every algorithm, OOM sweeptest_est_tls_roundtrip: an EST start without a TLS identity is refused before the CA is loadedTEST_CA_CFGtest_storeand the Zephyrwolfcert.unit.storesuite are removedBreaking changes
ca_storeleaves the middle ofWolfCertServerCfgSrv; the 1.0 SOVERSION bump covers itFenrir
These findings become obsolete and get closed after merge: F-12126, F-8028, F-8050, F-8019, F-11058, F-12860, F-12092, F-9822. F-16536 (Zephyr NVS store) becomes won't-fix.