|
| 1 | +# Validating GCM's GPG signature |
| 2 | + |
| 3 | +Follow the below instructions to import GCM's public key and use it to validate |
| 4 | +the latest Debian package and/or tarball signature. |
| 5 | + |
| 6 | +## Debian package |
| 7 | + |
| 8 | +```shell |
| 9 | +# Install needed packages |
| 10 | +apt-get install -y curl debsig-verify |
| 11 | + |
| 12 | +# Download public key signature file |
| 13 | +curl -s https://api.github.com/repos/git-ecosystem/git-credential-manager/releases/latest \ |
| 14 | +| grep -E 'browser_download_url.*gcm-public.asc' \ |
| 15 | +| cut -d : -f 2,3 \ |
| 16 | +| tr -d \" \ |
| 17 | +| xargs -I 'url' curl -L -o gcm-public.asc 'url' |
| 18 | + |
| 19 | +# De-armor public key signature file |
| 20 | +gpg --output gcm-public.gpg --dearmor gcm-public.asc |
| 21 | + |
| 22 | +# Note that the fingerprint of this key is "3C853823978B07FA", which you can |
| 23 | +# determine by running: |
| 24 | +gpg --show-keys gcm-public.asc | head -n 2 | tail -n 1 | tail -c 17 |
| 25 | + |
| 26 | +# Copy de-armored public key to debsig keyring folder |
| 27 | +mkdir /usr/share/debsig/keyrings/3C853823978B07FA |
| 28 | +mv gcm-public.gpg /usr/share/debsig/keyrings/3C853823978B07FA/ |
| 29 | + |
| 30 | +# Create an appropriate policy file |
| 31 | +mkdir /etc/debsig/policies/3C853823978B07FA |
| 32 | +cat > /etc/debsig/policies/3C853823978B07FA/generic.pol << EOL |
| 33 | +<?xml version="1.0"?> |
| 34 | +<!DOCTYPE Policy SYSTEM "https://www.debian.org/debsig/1.0/policy.dtd"> |
| 35 | +<Policy xmlns="https://www.debian.org/debsig/1.0/"> |
| 36 | +
|
| 37 | + <Origin Name="Git Credential Manager" id="3C853823978B07FA" Description="Git Credential Manager public key"/> |
| 38 | +
|
| 39 | + <Selection> |
| 40 | + <Required Type="origin" File="gcm-public.gpg" id="3C853823978B07FA"/> |
| 41 | + </Selection> |
| 42 | +
|
| 43 | + <Verification MinOptional="0"> |
| 44 | + <Required Type="origin" File="gcm-public.gpg" id="3C853823978B07FA"/> |
| 45 | + </Verification> |
| 46 | +
|
| 47 | +</Policy> |
| 48 | +EOL |
| 49 | + |
| 50 | +# Download Debian package |
| 51 | +curl -s https://api.github.com/repos/git-ecosystem/git-credential-manager/releases/latest \ |
| 52 | +| grep "browser_download_url.*deb" \ |
| 53 | +| cut -d : -f 2,3 \ |
| 54 | +| tr -d \" \ |
| 55 | +| xargs -I 'url' curl -L -o gcm.deb 'url' |
| 56 | + |
| 57 | +# Verify |
| 58 | +debsig-verify gcm.deb |
| 59 | +``` |
| 60 | + |
| 61 | +## Tarball |
| 62 | +```shell |
| 63 | +# Download the public key signature file |
| 64 | +curl -s https://api.github.com/repos/git-ecosystem/git-credential-manager/releases/latest \ |
| 65 | +| grep -E 'browser_download_url.*gcm-public.asc' \ |
| 66 | +| cut -d : -f 2,3 \ |
| 67 | +| tr -d \" \ |
| 68 | +| xargs -I 'url' curl -L -o gcm-public.asc 'url' |
| 69 | + |
| 70 | +# Import the public key |
| 71 | +gpg --import gcm-public.asc |
| 72 | + |
| 73 | +# Download the tarball and its signature file |
| 74 | +curl -s https://api.github.com/repos/ldennington/git-credential-manager/releases/latest \ |
| 75 | +| grep -E 'browser_download_url.*gcm-linux.*[0-9].[0-9].[0-9].tar.gz' \ |
| 76 | +| cut -d : -f 2,3 \ |
| 77 | +| tr -d \" \ |
| 78 | +| xargs -I 'url' curl -LO 'url' |
| 79 | + |
| 80 | +# Trust the public key |
| 81 | +echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key 3C853823978B07FA trust |
| 82 | + |
| 83 | +# Verify the signature |
| 84 | +gpg --verify gcm-linux_amd64*.tar.gz.asc gcm-linux*.tar.gz |
| 85 | +``` |
0 commit comments