Skip to content

Commit

Permalink
hack: ignore TLS hostname verification for spotifycdn.com
Browse files Browse the repository at this point in the history
Ignore subdomains / hostpart name for everything under spotifycdn.com
as those are (sometimes?) misconfigured.
The cert must be for *.spotifycdn.com and the requested host must
also be *.spotifycdn.com
  • Loading branch information
Stefan Keller committed Oct 20, 2023
1 parent 3c52fce commit 05c6d95
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/main/java/xyz/gianlu/librespot/core/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

/**
* @author Gianlu
Expand Down Expand Up @@ -144,6 +146,14 @@ private Session(@NotNull Inner inner) throws IOException {
private static OkHttpClient createClient(@NotNull Configuration conf) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.retryOnConnectionFailure(true);
builder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
if (hostname.toLowerCase().endsWith("spotifycdn.com") && session.getPeerHost().toLowerCase().endsWith("spotifycdn.com"))
return true;
return hostname.equalsIgnoreCase(session.getPeerHost());
}
});

if (conf.proxyEnabled && conf.proxyType != Proxy.Type.DIRECT) {
builder.proxy(new Proxy(conf.proxyType, new InetSocketAddress(conf.proxyAddress, conf.proxyPort)));
Expand Down

0 comments on commit 05c6d95

Please sign in to comment.