2021-05-24 17:49:58 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This script fetches the object signing list from the Microsoft list. It then
|
|
|
|
# mergest that list into the fetched certdata.txt.
|
|
|
|
#
|
2023-10-04 21:31:59 +00:00
|
|
|
giturl="https://github.com/dotnet/sdk"
|
|
|
|
gitrawurl="https://raw.githubusercontent.com/dotnet/sdk"
|
|
|
|
release="latest"
|
|
|
|
treedir="src/Layout/redist/trustedroots/codesignctl.pem"
|
|
|
|
target="microsoft_sign_obj_ca.pem"
|
2021-05-24 17:49:58 +00:00
|
|
|
certdata="./certdata.txt"
|
2023-10-04 21:31:59 +00:00
|
|
|
baseurl=""
|
2021-05-24 17:49:58 +00:00
|
|
|
merge=1
|
|
|
|
diff=0
|
2023-10-04 21:31:59 +00:00
|
|
|
|
|
|
|
function getlatest
|
|
|
|
{
|
|
|
|
local url=$1
|
|
|
|
local latest="0"
|
|
|
|
local tags=($(git ls-remote --tags ${url}))
|
|
|
|
for tag in "${tags[@]}"
|
|
|
|
do
|
|
|
|
if [[ ! ${tag} =~ refs/.* ]]; then
|
|
|
|
continue # skip hashes
|
|
|
|
fi
|
|
|
|
if [[ ${tag} =~ .*preview.* ]]; then
|
|
|
|
continue # skip preview tags, we only want release tags
|
|
|
|
fi
|
|
|
|
if [[ ${tag} =~ .*rc.* ]]; then
|
|
|
|
continue # skip release candidate tags, we only want release tags
|
|
|
|
fi
|
|
|
|
if [[ ${latest} < ${tag} ]]; then
|
|
|
|
latest=$tag
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
latest=${latest##refs/tags/}
|
|
|
|
echo $latest
|
|
|
|
}
|
|
|
|
|
2021-05-24 17:49:58 +00:00
|
|
|
while [ -n "$1" ]; do
|
|
|
|
case $1 in
|
2023-10-04 21:31:59 +00:00
|
|
|
"-g")
|
|
|
|
shift
|
|
|
|
giturl=$1
|
|
|
|
;;
|
|
|
|
"-r")
|
|
|
|
shift
|
|
|
|
gitrawurl=$1
|
|
|
|
;;
|
|
|
|
"-t")
|
|
|
|
shift
|
|
|
|
treedir=$1
|
|
|
|
;;
|
|
|
|
"-r")
|
|
|
|
shift
|
|
|
|
release=$1
|
|
|
|
;;
|
2021-05-24 17:49:58 +00:00
|
|
|
"-u")
|
|
|
|
shift
|
|
|
|
baseurl=$1
|
2023-10-04 21:31:59 +00:00
|
|
|
release="unknown"
|
2021-05-24 17:49:58 +00:00
|
|
|
;;
|
|
|
|
"-o")
|
|
|
|
shift
|
|
|
|
target=$1
|
|
|
|
;;
|
|
|
|
"-c")
|
|
|
|
shift
|
|
|
|
certdata=$1
|
|
|
|
;;
|
2021-05-25 23:48:57 +00:00
|
|
|
"-n")
|
2021-05-24 17:49:58 +00:00
|
|
|
merge=0
|
|
|
|
;;
|
|
|
|
"-d")
|
2023-10-04 21:31:59 +00:00
|
|
|
shift
|
2021-05-24 17:49:58 +00:00
|
|
|
diff=1
|
|
|
|
difffile=$1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usage: $0 [-u URL] [-o target] [-c certdata] [-n]"
|
2023-10-04 21:31:59 +00:00
|
|
|
echo "-g URL git URL to fetch code signing list"
|
|
|
|
echo "-r URL raw git URL to fetch code signing list"
|
|
|
|
echo "-t URL git tree directory to fetch code signing list"
|
|
|
|
echo "-r release code signing list release version"
|
2021-05-24 17:49:58 +00:00
|
|
|
echo "-u URL base URL to fetch code signing list"
|
|
|
|
echo "-o target name of the codesigning target"
|
|
|
|
echo "-c certdata patch to certdata.txt to merge with"
|
|
|
|
echo "-d diff optional diff file"
|
|
|
|
echo "-n don't merge"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2023-10-04 21:31:59 +00:00
|
|
|
if [ "${release}" = "latest" ]; then
|
|
|
|
release=$(getlatest ${giturl} )
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${baseurl}" = "" ]; then
|
|
|
|
baseurl="${gitrawurl}/${release}/${treedir}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $release > "./codesign-release.txt"
|
|
|
|
|
|
|
|
echo "Fetching release=${release}, ${target} from ${baseurl}"
|
2021-05-24 17:49:58 +00:00
|
|
|
|
|
|
|
wget ${baseurl} -O ${target}
|
|
|
|
|
|
|
|
if [ ${merge} -eq 0 ]; then
|
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
out=${certdata}
|
2021-05-25 23:48:57 +00:00
|
|
|
if [ ${diff} -eq 1 ]; then
|
2021-05-24 17:49:58 +00:00
|
|
|
out=${certdata}.out
|
|
|
|
fi
|
|
|
|
python3 ./mergepem2certdata.py -c "${certdata}" -p "${target}" -o "${out}" -t "CKA_TRUST_CODE_SIGNING" -l "Microsoft Code Signing Only Certificate"
|
|
|
|
|
|
|
|
if [ ${diff} -eq 1 ]; then
|
|
|
|
diff -u ${certdata} ${out} > ${difffile}
|
|
|
|
mv ${out} ${certdata}
|
|
|
|
fi
|