summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2019-02-27 09:01:03 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-02-27 09:01:03 +0000
commit1b9adbfdd1f18cb16e82f9a6f158d3ac242fffa1 (patch)
tree659494ac95ea624338fb5859b9923cbd8c282d28
parent909baeddfab43c12bfc5be53f35786fdb8e80a4a (diff)
parent19254043ae69f0569ab0dae20e7d571dccc8bb29 (diff)
Merge "Use public APIs instead of Conscrypt ones"
-rw-r--r--core/java/android/net/SSLCertificateSocketFactory.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index 90dccb5b82d5..45860b3858ce 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -23,8 +23,7 @@ import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.RoSystemProperties;
-import com.android.org.conscrypt.Conscrypt;
-import com.android.org.conscrypt.OpenSSLContextImpl;
+import com.android.org.conscrypt.ClientSessionContext;
import com.android.org.conscrypt.OpenSSLSocketImpl;
import com.android.org.conscrypt.SSLClientSessionCache;
@@ -33,6 +32,8 @@ import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
@@ -40,6 +41,7 @@ import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
@@ -251,11 +253,12 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
private SSLSocketFactory makeSocketFactory(
KeyManager[] keyManagers, TrustManager[] trustManagers) {
try {
- OpenSSLContextImpl sslContext = (OpenSSLContextImpl) Conscrypt.newPreferredSSLContextSpi();
- sslContext.engineInit(keyManagers, trustManagers, null);
- sslContext.engineGetClientSessionContext().setPersistentCache(mSessionCache);
- return sslContext.engineGetSocketFactory();
- } catch (KeyManagementException e) {
+ SSLContext sslContext = SSLContext.getInstance("TLS", "AndroidOpenSSL");
+ sslContext.init(keyManagers, trustManagers, null);
+ ((ClientSessionContext) sslContext.getClientSessionContext())
+ .setPersistentCache(mSessionCache);
+ return sslContext.getSocketFactory();
+ } catch (KeyManagementException | NoSuchAlgorithmException | NoSuchProviderException e) {
Log.wtf(TAG, e);
return (SSLSocketFactory) SSLSocketFactory.getDefault(); // Fallback
}