<!--
GitHub is reserved for bug reports and feature requests; it is not the place
for general questions. If you have a question or an unconfirmed bug , please
visit the [forums](https://discuss.elastic.co/c/elasticsearch).  Please also
check your OS is [supported](https://www.elastic.co/support/matrix#show_os).
If it is not, the issue is likely to be closed.

For security vulnerabilities please only send reports to security@elastic.co.
See https://www.elastic.co/community/security for more information.

Please fill in the following details to help us reproduce the bug:
-->

**Elasticsearch version** (`bin/elasticsearch --version`): `Version: 7.13.2, Build: default/deb/4d960a0733be83dd2543ca018aa4ddc42e956800/2021-06-10T21:01:55.251515791Z, JVM: 16`

**Plugins installed**: []

**JVM version** (`java -version`): `openjdk 16 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)`

**OS version** (`uname -a` if on a Unix-like system): `Linux lk-elastic-data-6 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux`

**Description of the problem including expected versus actual behavior**: 

Context, I would like to add 3 nodes to an existing cluster, **all of the 3 servers** are fresh install of debian10, and all of them get the same behavior

**Steps to reproduce**:

 1. Install any plugin
 `/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji`
 2. Hang for a long period without any reason

For repository-gcs it hang for 10-15min before asking y/N
```-> Installing repository-gcs
-> Downloading repository-gcs from elastic
[=================================================] 100%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission setFactory
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.net.SocketPermission * connect,resolve
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]
```

Additionnal information, installing with file:///path/plugin.zip works without hanging, and the plugin install do not respect os proxy I was trying to follow if it was an http request that hang.

**Provide logs (if relevant)**:

2 jstack

https://gist.github.com/PMickael/293f0bc431926fe95f7fe15332d72145
https://gist.github.com/PMickael/0f05418a32b9999f04d274d407af1533
distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java
final String shaExtension,
        final Function<byte[], String> shaCalculator,
        final PGPSecretKey secretKey,
        final BiFunction<byte[], PGPSecretKey, String> signature
    ) throws Exception {
        PluginDescriptor pluginZip = createPlugin(pluginId, pluginDir);
        Path pluginZipPath = Path.of(URI.create(pluginZip.getLocation()));
        InstallPluginAction action = new InstallPluginAction(terminal, env.v2(), false) {
            @Override
            Path downloadZip(String urlString, Path tmpDir) throws IOException {
                assertEquals(url, urlString);
                Path downloadedPath = tmpDir.resolve("downloaded.zip");
                Files.copy(pluginZipPath, downloadedPath);
                return downloadedPath;
            }
            @Override
            URL openUrl(String urlString) throws IOException {
                if ((url + shaExtension).equals(urlString)) {
                    
                    Path shaFile = temp.apply("shas").resolve("downloaded.zip" + shaExtension);
                    byte[] zipbytes = Files.readAllBytes(pluginZipPath);
                    String checksum = shaCalculator.apply(zipbytes);
                    Files.write(shaFile, checksum.getBytes(StandardCharsets.UTF_8));
                    return shaFile.toUri().toURL();
                } else if ((url + ".asc").equals(urlString)) {
                    final Path ascFile = temp.apply("asc").resolve("downloaded.zip" + ".asc");
                    final byte[] zipBytes = Files.readAllBytes(pluginZipPath);
                    final String asc = signature.apply(zipBytes, secretKey);
                    Files.write(ascFile, asc.getBytes(StandardCharsets.UTF_8));
                    return ascFile.toUri().toURL();