Skip to content

Instantly share code, notes, and snippets.

@alessandromrc
Created July 25, 2022 14:46
Show Gist options
  • Save alessandromrc/137fc59a3214fa84974dfb13db76e760 to your computer and use it in GitHub Desktop.
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
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