Last active
May 10, 2022 11:32
-
-
Save yawn/d2a6b8264780870cf9513d180f71c51a to your computer and use it in GitHub Desktop.
GPG encrypt to all recipients in security.txt
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
#!/bin/bash | |
set -euo pipefail | |
keys=$(sed -n 's/^Encryption: //p' security.txt) | |
declare -a receivers | |
for key in $keys | |
do | |
# fetch key manually (we can't using --auto-key-locate clear,local,wkd --locate-key since the recipients might be different from the security email address) | |
t=$(mktemp) | |
$(curl -sLo $t $key) | |
# get id of first public key | |
id=$(gpg --with-fingerprint --with-colons $t | sed -rn 's/fpr:::::::::(.*):/\1/p') | |
# import key | |
$(gpg --import $t) | |
# populate recipient list using key ids | |
receivers+=("--recipient=$id") | |
# remove downloaded key | |
$(rm $t) | |
done | |
gpg --armor --trust-model always --encrypt ${receivers[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment