I'm building my own firmware for my devices, nothing non standard.
I encountered problems during sysupgrade which led me to conclusion that there may ne bugs in ucert.
Process
from sysupgrade commandline i got error "Image check failed"
I sourced it to the lack of 'valid=true' in /usr/libexec/validate_firmware_image
it was because /lib/upgrade/fwtool.sh fwtool_check_signature failed on command:
fwtool -q -T -s /dev/null "$1" | ucert -V -m - -c "/tmp/sysupgrade.ucert" -P /etc/opkg/keys
i then checked that keys and certs are present, fwtool works on device, and firmware has signature attached (fwtool -s filetocheck firmware.bin)
I then checked, learned and then manually recreated adding signature to the firmware file on the build machine (ucert, usign, fwtool) but it resulted in the same firmware (same signature added)
I narrowed it down to the key-build.ucert file (which looks more/less ok(*)), so I recreated it from scratch but got the same problem
I then search how cert verification is done, patched ucert.c to check where exactly the problem is
Looks like the problem starts in cert_load function around blob_parse_untrusted function which reports 'no attributes found'
Here I stopped my learning journey, asking for help or guidance for next steps
(*) the only thing which makes me wonder is why key-build.ucert contains binary data, while other files (pub, priv, sig) are text only. Maybe thats a problem? However I used default key-builds in the process, and they were generated by standard openwrt build process (package/base-files/Makefile is the place of key-build generation)