Но переход по URL-адресу в моем браузере работает. И завивка для файла работает:
Код: Выделить всё
curl https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-spark-extensions-3.5_2.12/1.5.2/iceberg-spark-extensions-3.5_2.12-1.5.2.pom -O
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5911 100 5911 0 0 56927 0 --:--:-- --:--:-- --:--:-- 57388
Диагностическая программа:
String fileUrl = "https://repo1.maven.org/maven2/org/ apache/iceberg/iceberg-spark-extensions-3.5_2.12/1.5.2/iceberg-spark-extensions-3.5_2.12-1.5.2.pom";
String outputFilePath = "iceberg-spark-extensions -3.5_2.12-1.5.2.пом";
Код: Выделить всё
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(fileUrl))
.GET()
.build();
try {
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
if (response.statusCode() == 200) {
Files.write(Paths.get(outputFilePath), response.body(), StandardOpenOption.CREATE);
System.out.println("File downloaded successfully: " + outputFilePath);
} else {
System.out.println("Failed to download file. HTTP status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
Код: Выделить всё
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:956)
at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:133)
at com.zscaler.zfabric.management.services.Main.main(Main.java:98)
Код: Выделить всё
export JAVA_TOOL_OPTIONS="-Djavax.net.ssl.trustStoreType=KeychainStore"
Что может быть не так?
Подробнее здесь: https://stackoverflow.com/questions/791 ... s-download
Мобильная версия