ESP32: best way to embed certificates I'm using the Arduino framework on an ESP32 based board. The board has an SD card slot, but I'm not going to use it.
Anyway, I need to store somewhere the certificates. To the the firmware I've just hardcoded them into the code:
const char *rootCABuff = \
&quot;-----BEGIN CERTIFICATE-----\n&quot; \
&quot;MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n&quot; \
...
&quot;hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n&quot; \
&quot;-----END CERTIFICATE-----\n&quot;;

const char certificateBuff[] = \
&quot;-----BEGIN CERTIFICATE-----\n&quot; \
&quot;MIIDWTCCAkGgAwIBAgIUZXjPNnJFXMntXOki9BT+QmDFciUwDQYJKoZIhvcNAQEL\n&quot; \
...
&quot;gGXtqlgPnenkZPTaBr9c8o+WjgQXFLM+Jwnw3/53dUI9zBcybTaptI63o3Ct\n&quot; \
&quot;-----END CERTIFICATE-----\n&quot;;

const char privateKeyBuff[] = \
&quot;-----BEGIN RSA PRIVATE KEY-----\n&quot; \
&quot;MIIEpAIBAAKCAQEAuuKsFy98/xsJclnWo0d+qm8KImLEILB64BbH7WaYi3NnznLg\n&quot; \
...
&quot;uHfBLQQDrA0HDRvYpAUNw/b2H4dpUK/nGM4FFVMP7V8RM2t2923nhQ==\n&quot; \
&quot;-----END RSA PRIVATE KEY-----\n&quot;;

Of course this is not suitable for production where each unit will have a different set of certificates.
So wonder what is the best way to store them.
The obviously idea is into flash. So I tried to enhance my settings class, based upon the Preferences library. In the official documentation I read:

String values are currently limited to 4000 bytes. This includes the null terminator. Blob values are limited to 508000 bytes or 97.6% of the partition size - 4000 bytes, whichever is lower.

But if I do something like this:
Preferences prefs;
prefs.begin(&quot;settings&quot;, false);
Serial.println(prefs.freeEntries());

it return 460, even if I still have plenty of flash:
Flash: [=======   ]  73.8% (used 967234 bytes from 1310720 bytes)

Is there another library more suitable to store such a data that can be used with Preferences?
I don't know what you need that Preferences thing for, but I would use SPIFFS/FAT anyway. Simply store the certificate in a file in flash and read that file when you need it. The required space is no problem as you can choose the size for file system in the partition table and also you can upload the file (there is a plugin in the arduino IDE for this purpose) after flashing the firmware, so having different certificates on individual devices is no problem.
I saw that you tagged the question with 'eeprom': the esp has no eeprom but emulates it with a blob in flash, so using any flash library is just as fine. The esp also supports wear-leveling, which makes using flash an even better option as the dedicated eeprom-partition, which was used in an older version of the sdk, would wear out orherwise. The &quot;eeprom&quot; is just there to be consistent with the use of other arduino's eeproms.