Created
July 25, 2022 14:46
-
-
Save alessandromrc/137fc59a3214fa84974dfb13db76e760 to your computer and use it in GitHub Desktop.
Generate certificates.h for Portenta H7 in order to connect to websites that use SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -z "$1" ]; | |
then echo "execute ./get_certificate.sh <domain_name>"; | |
else | |
openssl s_client -showcerts -connect ["$1"]:443 </dev/null | sed -n -e '/-.BEGIN/,/-.END/ p' > certifs.pem | |
xxd -i certifs.pem </dev/null | sed -e 's/unsigned char .* = {/const unsigned char cacert_pem[] = {/g' -e 's/unsigned int .* = .*;//g' > certificates.h | |
echo "unsigned int cacert_pem_len = sizeof(cacert_pem);" >> certificates.h | |
rm certifs.pem | |
echo "Done, check certificates.h!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment