px5g-mbedtls is the small certificate tool most OpenWrt images already have, but it can only make self-signed, non-CA certificates. To give LAN devices proper certificates (one home CA, trusted once on phones and laptops, signing the router and access points) you currently need OpenSSL – about 1.5 MB, which many small routers simply don't have.
Proposal: two small additions to px5g-mbedtls, using only libmbedtls:
px5g ca -newkey ec -days 3650 -subj /CN=Home CA -keyout ca.key -out ca.crt [-addext nameConstraints=permitted;DNS:lan,...]
→ a CA certificate (basicConstraints CA:TRUE, keyUsage keyCertSign/cRLSign)
px5g sign -cakey ca.key -cacert ca.crt -newkey ec -days 397 -subj /CN=router.lan -addext subjectAltName=DNS:router.lan,IP:192.168.1.1 -keyout router.key -out router.crt
→ a server certificate signed by that CA (serverAuth)
Same option style as the existing selfsigned command, a few hundred lines of C, no new dependencies.
Use case: a home network app (LuCI) that creates a home CA and certificates for the router and its access points, with renewal, on routers without room for OpenSSL. It would equally help anyone who wants https on their LAN without browser warnings.
Would a patch along these lines be welcome? Any preferences on command names or options before I start? A first concept is drafted by Claude - AI in C code.
Thanks!
To be clear about scope: this is not a CA toolkit. It adds the minimum for a small home CA: one CA certificate and signing server certificates for the routers. There are no CSRs, CRLs or OCSP, no intermediates, no issued-certificate database, and no PKCS#12. Anyone who needs more installs openssl-util. The point is that the common case (LuCI https without warnings on a few routers) works with what is already on the image, for a few KB.
Client certificates:px5g sign ... -addext extendedKeyUsage=clientAuth now makes a client certificate without a subjectAltName, e.g. for OpenVPN. A server certificate still needs at least one subjectAltName.
Patch series for master: (1) ca and sign, (2) name constraints for ca. Each has a commit message and a PKG_RELEASE bump, builds on its own with -Wall -Werror, and the series applies with git am.
Tests: 50 checks in test.sh, every result verified with openssl verify -x509_strict, also under AddressSanitizer/UBSan.
Targets and size, built like OpenWrt builds px5g (musl, -Os, linked to mbedtls 3.6 as configured in 25.12):
Target
original
with ca/sign
tested
aarch64_cortex-a53
13.7 KB
26.0 KB
real router (daily use) + qemu
mipsel_24kc
12.0 KB
25.6 KB
qemu
mips_24kc
12.0 KB
25.6 KB
qemu
arm_cortex-a7
11.3 KB
23.4 KB
qemu
On my Cudy WR3000 (25.12.6) it is in daily use for a small home CA (LAN HTTPS) and for OpenVPN 2.7/mbed TLS client certificates, which OpenVPN accepts.
selfsigned, eckey and rsakey are unchanged. It is not a full CA: no CRLs/revocation (for OpenVPN I block a client with a ccd disable file), no CSR handling, no encrypted keys.
Help welcome:
Testers on real MIPS or ARMv7 routers. So far only emulated; the README section "Try it on your own router" has the SDK build and three commands to run. Please report target, result and size.
Feedback on whether this belongs in px5g at all, or should be a separate package or stay OpenSSL's job.
As before: I'm not a C programmer; the code was written with Claude and tested by me. Everything is LGPL-2.1 like px5g, and the patches carry no Signed-off-by yet, so a maintainer is free to take it over and rework it.