Skip to content

Commit 17c0664

Browse files
authored
Merge pull request #852 from nanjj/gpgproxy
Support http-proxy keyserver options for gpg recv-keys
2 parents e468d2b + 092eab7 commit 17c0664

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sources/utils.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ func recvGPGKeys(ctx context.Context, gpgDir string, keyserver string, keys []st
168168

169169
if keyserver != "" {
170170
args = append(args, "--keyserver", keyserver)
171+
httpProxy := getEnvHttpProxy()
172+
if httpProxy != "" {
173+
args = append(args, "--keyserver-options",
174+
fmt.Sprintf("http-proxy=%s", httpProxy))
175+
}
171176
}
172177

173178
args = append(args, append([]string{"--recv-keys"}, fingerprints...)...)
@@ -216,3 +221,14 @@ func recvGPGKeys(ctx context.Context, gpgDir string, keyserver string, keys []st
216221

217222
return true, nil
218223
}
224+
225+
func getEnvHttpProxy() (httpProxy string) {
226+
for _, key := range []string{"http_proxy",
227+
"HTTP_PROXY", "https_proxy", "HTTPS_PROXY"} {
228+
if httpProxy = os.Getenv(key); httpProxy != "" {
229+
return
230+
}
231+
}
232+
233+
return
234+
}

0 commit comments

Comments
 (0)