1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
From: Markus Koschany <apo@debian.org>
Date: Sun, 10 Feb 2019 11:03:45 +0100
Subject: no Conscrypt
---
.../internal/platform/ConscryptPlatform.java | 122 ---------------------
.../java/okhttp3/internal/platform/Platform.java | 2 +-
2 files changed, 1 insertion(+), 123 deletions(-)
delete mode 100644 okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java
diff --git a/okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java b/okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java
deleted file mode 100644
index e460595..0000000
--- a/okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2014 Square, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package okhttp3.internal.platform;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.util.List;
-import javax.annotation.Nullable;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.X509TrustManager;
-import okhttp3.Protocol;
-import org.conscrypt.Conscrypt;
-
-/**
- * Platform using Conscrypt (conscrypt.org) if installed as the first Security Provider.
- *
- * Requires org.conscrypt:conscrypt-openjdk-uber on the classpath.
- */
-public class ConscryptPlatform extends Platform {
- private ConscryptPlatform() {
- }
-
- private Provider getProvider() {
- return Conscrypt.newProviderBuilder().provideTrustManager().build();
- }
-
- @Override public @Nullable X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
- if (!Conscrypt.isConscrypt(sslSocketFactory)) {
- return super.trustManager(sslSocketFactory);
- }
-
- try {
- // org.conscrypt.SSLParametersImpl
- Object sp =
- readFieldOrNull(sslSocketFactory, Object.class, "sslParameters");
-
- if (sp != null) {
- return readFieldOrNull(sp, X509TrustManager.class, "x509TrustManager");
- }
-
- return null;
- } catch (Exception e) {
- throw new UnsupportedOperationException(
- "clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on Conscrypt", e);
- }
- }
-
- @Override public void configureTlsExtensions(
- SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
- if (Conscrypt.isConscrypt(sslSocket)) {
- // Enable SNI and session tickets.
- if (hostname != null) {
- Conscrypt.setUseSessionTickets(sslSocket, true);
- Conscrypt.setHostname(sslSocket, hostname);
- }
-
- // Enable ALPN.
- List<String> names = Platform.alpnProtocolNames(protocols);
- Conscrypt.setApplicationProtocols(sslSocket, names.toArray(new String[0]));
- } else {
- super.configureTlsExtensions(sslSocket, hostname, protocols);
- }
- }
-
- @Override public @Nullable String getSelectedProtocol(SSLSocket sslSocket) {
- if (Conscrypt.isConscrypt(sslSocket)) {
- return Conscrypt.getApplicationProtocol(sslSocket);
- } else {
- return super.getSelectedProtocol(sslSocket);
- }
- }
-
- @Override public SSLContext getSSLContext() {
- try {
- return SSLContext.getInstance("TLSv1.3", getProvider());
- } catch (NoSuchAlgorithmException e) {
- try {
- // Allow for Conscrypt 1.2
- return SSLContext.getInstance("TLS", getProvider());
- } catch (NoSuchAlgorithmException e2) {
- throw new IllegalStateException("No TLS provider", e);
- }
- }
- }
-
- public static ConscryptPlatform buildIfSupported() {
- try {
- // Trigger an early exception over a fatal error, prefer a RuntimeException over Error.
- Class.forName("org.conscrypt.Conscrypt");
-
- if (!Conscrypt.isAvailable()) {
- return null;
- }
-
- return new ConscryptPlatform();
- } catch (ClassNotFoundException e) {
- return null;
- }
- }
-
- @Override
- public void configureSslSocketFactory(SSLSocketFactory socketFactory) {
- if (Conscrypt.isConscrypt(socketFactory)) {
- Conscrypt.setUseEngineSocket(socketFactory, true);
- }
- }
-}
diff --git a/okhttp/src/main/java/okhttp3/internal/platform/Platform.java b/okhttp/src/main/java/okhttp3/internal/platform/Platform.java
index fdfd244..67888bf 100644
--- a/okhttp/src/main/java/okhttp3/internal/platform/Platform.java
+++ b/okhttp/src/main/java/okhttp3/internal/platform/Platform.java
@@ -206,7 +206,7 @@ public class Platform {
}
if (isConscryptPreferred()) {
- Platform conscrypt = ConscryptPlatform.buildIfSupported();
+ Platform conscrypt = null;
if (conscrypt != null) {
return conscrypt;
|