Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Git-Lfs] - Solution to #1072 issue - Can't download public key #1124

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/git-lfs/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,33 @@ find_version_from_git_tags() {

# Get the list of GPG key servers that are reachable
get_gpg_key_servers() {
gauravsaini04 marked this conversation as resolved.
Show resolved Hide resolved
declare -A keyservers_curl_map=(
["hkp://keyserver.ubuntu.com"]="http://keyserver.ubuntu.com:11371"
["hkp://keyserver.ubuntu.com:80"]="http://keyserver.ubuntu.com"
["hkps://keys.openpgp.org"]="https://keys.openpgp.org"
["hkp://keyserver.pgp.com"]="http://keyserver.pgp.com:11371"
)

local curl_args=""
local keyserver_reachable=false # Flag to indicate if any keyserver is reachable

if [ ! -z "${KEYSERVER_PROXY}" ]; then
curl_args="--proxy ${KEYSERVER_PROXY}"
fi

for keyserver in "${!keyservers_curl_map[@]}"; do
local keyserver_curl_url="${keyservers_curl_map[${keyserver}]}"
if curl -s ${curl_args} --max-time 5 ${keyserver_curl_url} > /dev/null; then
test_keyserver() {
local keyserver="$1"
local keyserver_curl_url="$2"
if curl -s ${curl_args} --max-time 5 "${keyserver_curl_url}" > /dev/null; then
echo "keyserver ${keyserver}"
keyserver_reachable=true
else
echo "(*) Keyserver ${keyserver} is not reachable." >&2
fi
done
}

# Explicitly test these in order because Bash v4.4.20 (Ubuntu Bionic)
# enumerates associative array keys in a different order than Bash v5
test_keyserver "hkp://keyserver.ubuntu.com" "http://keyserver.ubuntu.com:11371"
test_keyserver "hkp://keyserver.ubuntu.com:80" "http://keyserver.ubuntu.com"
test_keyserver "hkp://keyserver.pgp.com" "http://keyserver.pgp.com:11371"
# Test this server last because keys.openpgp.org strips user IDs from keys unless
# the owner gives permission, which causes gpg in Ubuntu Bionic to reject the key
# (https://github.com/devcontainers/features/issues/1055)
test_keyserver "hkps://keys.openpgp.org" "https://keys.openpgp.org"

if ! $keyserver_reachable; then
echo "(!) No keyserver is reachable." >&2
Expand Down