Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'org.jmdns:jmdns:3.5.9'
implementation 'com.github.cgutman:ShieldControllerExtensions:1.0.1'
implementation "org.conscrypt:conscrypt-android:2.5.2"
}
21 changes: 21 additions & 0 deletions app/src/main/java/com/limelight/nvstream/http/NvHTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
Expand All @@ -42,6 +44,7 @@
import javax.net.ssl.X509KeyManager;
import javax.net.ssl.X509TrustManager;

import org.conscrypt.Conscrypt;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
Expand Down Expand Up @@ -172,7 +175,25 @@ public boolean verify(String hostname, SSLSession session) {
}
};

Provider conscrypt = Conscrypt.newProvider();
Security.insertProviderAt(conscrypt, 1);

TrustManager[] trustManagers = null;
SSLContext sslContext = null;
SSLSocketFactory sslSocketFactory = null;
try {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init((KeyStore) null);
trustManagers = tmf.getTrustManagers();
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustManagers, new SecureRandom());
sslSocketFactory = sslContext.getSocketFactory();
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
throw new RuntimeException(e);
}

httpClientLongConnectTimeout = new OkHttpClient.Builder()
.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustManagers[0])
.connectionPool(new ConnectionPool(0, 1, TimeUnit.MILLISECONDS))
.hostnameVerifier(hv)
.readTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS)
Expand Down