Enforce modern TLS1.2+

This fixes the following problem:
Bandcamp/their Fastly CDN fails with 403 responses when running tests
* on Windows
* with Java 17+
* and OkHttp's APPROVED_CIPHER_SUITES (default) are used
This commit is contained in:
litetex 2025-02-11 20:43:55 +01:00
parent 12e2145185
commit 351174a85f
No known key found for this signature in database
GPG Key ID: 525B43E6039B3689

View File

@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -14,6 +15,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import okhttp3.ConnectionSpec;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
@ -28,8 +30,13 @@ public final class DownloaderTestImpl extends Downloader {
private final RateLimitedClientWrapper clientWrapper; private final RateLimitedClientWrapper clientWrapper;
private DownloaderTestImpl(final OkHttpClient.Builder builder) { private DownloaderTestImpl(final OkHttpClient.Builder builder) {
this.clientWrapper = new RateLimitedClientWrapper( this.clientWrapper = new RateLimitedClientWrapper(builder
builder.readTimeout(30, TimeUnit.SECONDS).build()); .readTimeout(30, TimeUnit.SECONDS)
// Required for certain services
// For example Bandcamp otherwise fails on Windows with Java 17+
// as their Fastly-CDN returns 403
.connectionSpecs(Arrays.asList(ConnectionSpec.RESTRICTED_TLS))
.build());
} }
/** /**