aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java29
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/RemoteController.java3
2 files changed, 31 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
index cb8871a0..913e30bf 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
@@ -86,7 +86,11 @@ import java.util.zip.GZIPInputStream;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
public class RESTMusicService implements MusicService {
@@ -102,6 +106,7 @@ public class RESTMusicService implements MusicService {
private static final int HTTP_REQUEST_MAX_ATTEMPTS = 5;
private static final long REDIRECTION_CHECK_INTERVAL_MILLIS = 60L * 60L * 1000L;
+ private SSLSocketFactory sslSocketFactory;
private HostnameVerifier selfSignedHostnameVerifier;
private long redirectionLastChecked;
private int redirectionNetworkType = -1;
@@ -111,6 +116,26 @@ public class RESTMusicService implements MusicService {
private boolean hasInstalledGoogleSSL = false;
public RESTMusicService() {
+ TrustManager[] trustAllCerts = new TrustManager[]{
+ new X509TrustManager() {
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ public void checkClientTrusted(
+ java.security.cert.X509Certificate[] certs, String authType) {
+ }
+ public void checkServerTrusted(
+ java.security.cert.X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+ try {
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
+ sslSocketFactory = sslContext.getSocketFactory();
+ } catch (Exception e) {
+ }
+
selfSignedHostnameVerifier = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
@@ -1868,6 +1893,7 @@ public class RESTMusicService implements MusicService {
if(connection instanceof HttpsURLConnection) {
HttpsURLConnection sslConnection = (HttpsURLConnection) connection;
+ sslConnection.setSSLSocketFactory(sslSocketFactory);
sslConnection.setHostnameVerifier(selfSignedHostnameVerifier);
}
@@ -1968,6 +1994,9 @@ public class RESTMusicService implements MusicService {
}
}
+ public SSLSocketFactory getSSLSocketFactory() {
+ return sslSocketFactory;
+ }
public HostnameVerifier getHostNameVerifier() {
return selfSignedHostnameVerifier;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/service/RemoteController.java b/app/src/main/java/github/daneren2005/dsub/service/RemoteController.java
index c6702e3e..617144d7 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/RemoteController.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/RemoteController.java
@@ -117,7 +117,8 @@ public abstract class RemoteController {
protected WebProxy createWebProxy() {
MusicService musicService = MusicServiceFactory.getMusicService(downloadService);
if(musicService instanceof CachedMusicService) {
- return new WebProxy(downloadService, ((CachedMusicService)musicService).getMusicService().getHostNameVerifier());
+ RESTMusicService restMusicService = ((CachedMusicService)musicService).getMusicService();
+ return new WebProxy(downloadService, restMusicService.getSSLSocketFactory(), restMusicService.getHostNameVerifier());
} else {
return new WebProxy(downloadService);
}