While uploading a pem format certificate I got a "Request entity to large" error.
This "Request entity to large" error is because a 500 error is being redirected and masking the real bug. The 500 error was:
Failed to execute call dispatcher target for entry '/admin/system/admin/certificates/import'.
The called action terminated with an exception:
/usr/lib/lua/luci/model/certificate.lua:101: field 'day' missing in date table
[C]: in function 'time'
/usr/lib/lua/luci/model/certificate.lua:101: in function 'import_certificate'
/usr/lib/lua/luci/controller/administration.lua:273: in function
(tail call): ?
The issue is in wrong parsing of output from the 'openssl' command, or, to be more precise, in parsing of certificate expiry date in openssl output.
If we run the command manually, as in certificate.lua:
$ /usr/bin/openssl x509 -in certificate.crt -dates -noout
We get the following:
notBefore=May 7 00:00:00 2020 GMT
notAfter=Jul 6 12:00:00 2022 GMT
Notice the 2 white spaces between Jul and 6. The pattern used in /usr/lib/lua/luci/model/certificate.lua:101 expects only 1 space.
"(%a+) (%d+) (%d+):(%d+):(%d+) (%d+) GMT"
I suspect if my expiry was 'Jul 16' this bug would not appear. Openssl probably left aligns the day, hence single digit dates are padded with an extra white space.
I should mention the firmware is RUTX_R_00.02.04.3.