Page 1 of 1

Share embedded certificates between projects

Posted: Mon Feb 03, 2020 12:57 am
by zliudr
I am using Make. I have several projects that share a few certificates that I want to relocate to a folder say common_files. I tried a few times to do this but couldn't get it to work, although I managed to keep common files such as code and include to work.

Currently I have in component.mk in the same folder as the main code, this line:

COMPONENT_EMBED_TXTFILES += BaltimoreCyberTrustRoot.pem

This embeds the cert so I don't have to mess with saving it to spiffs or sd card. I wonder what to do to share it with other projects.

Desired:

./common_files/
BaltimoreCyberTrustRoot.pem

./iot_project/
main.c

How do we help Make do this? Thanks.

Re: Share embedded certificates between projects

Posted: Mon Feb 03, 2020 8:49 am
by ESP_Sprite
You could make common_files into a component (by dropping a component.mk into the dir), then use EXTRA_COMPONENT_DIRS in the project makefile to refer to that path.

Re: Share embedded certificates between projects

Posted: Mon Feb 03, 2020 8:31 pm
by zliudr
ESP_Sprite wrote:
Mon Feb 03, 2020 8:49 am
You could make common_files into a component (by dropping a component.mk into the dir), then use EXTRA_COMPONENT_DIRS in the project makefile to refer to that path.
I think I did that since I am compiling fine with all my common files in that common folder and an empty component.mk. Should I include the cert in common_files's component.mk or in my project main folder's component.mk? I tried the latter with relative path etc. and that didn't work. Make couldn't find the cert.

A better way is to turn it into a .h or .c file and change my code ;)