#!/bin/bash
LICENSE_FILE="${HOME}/.config/WickedDocs/license.txt"
if [ ! -f "${LICENSE_FILE}" ]
then
echo "License file not found here or not a file: ${LICENSE_FILE}"
exit 1
fi
PATH=/usr/local/Cellar/openssl@1.1/1.1.1d/bin:$PATH
openssl version
openssl rsa -in ../Website/private-key.pem -pubout -out .tmp.key
cat ~/.config/WickedDocs/license.txt | grep -v "^---*" | grep "^Signature.*" | sed 's/^Signature[0-9] *= \(.*\)/\1/' | base64 -d > .tmp.sig
cat ~/.config/WickedDocs/license.txt | grep -v "^---*" | grep -v "^$" | grep -v "^Signature.*" | openssl dgst -sha256 -signature .tmp.sig -verify .tmp.key
rm .tmp.sig .tmp.key