Пытаюсь написать программу, которая будет скачивать файл mp4 с удаленного ресурса по ссылке, однако получаю exception:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
OutputStream outStream = null;
InputStream is = null;
HttpURLConnection conn;
try {
URL url;
byte[] buf;
int byteRead, byteWritten = 0;
url = new URL(getFinalLocation("https://cdn-1.watchenga.tv/movies/the-cabin-in-the-woods/original_360.mp4"));
outStream = new BufferedOutputStream(new FileOutputStream("test.mp4"));
conn = (HttpURLConnection) url.openConnection();
is = conn.getInputStream();
buf = new byte[1024];
while ((byteRead = is.read(buf)) != -1) {
outStream.write(buf, 0, byteRead);
byteWritten += byteRead;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
// is.close();
// outStream.close();
}
http
, а неhttps
. Исходя из ошибки он не может найти сертификат. stackoverflow.com/a/12146838/4444092