mirror of
https://github.com/square/okhttp.git
synced 2025-12-25 00:01:02 +03:00
New okhttp-tls module
This commit is contained in:
@@ -36,12 +36,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mockwebserver</artifactId>
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mockwebserver</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.InputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
@@ -31,7 +31,7 @@ import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
/** Benchmark Apache HTTP client. */
|
||||
class ApacheHttpClient extends SynchronousHttpClient {
|
||||
|
||||
@@ -32,11 +32,11 @@ import okhttp3.mockwebserver.Dispatcher;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.GzipSink;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
/**
|
||||
* This benchmark is fake, but may be useful for certain relative comparisons. It uses a local
|
||||
|
||||
@@ -44,9 +44,9 @@ import java.util.Deque;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
/** Netty isn't an HTTP client, but it's almost one. */
|
||||
class NettyHttpClient implements HttpClient {
|
||||
|
||||
@@ -25,9 +25,9 @@ import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
class OkHttp extends SynchronousHttpClient {
|
||||
private static final boolean VERBOSE = false;
|
||||
|
||||
@@ -31,9 +31,9 @@ import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
class OkHttpAsync implements HttpClient {
|
||||
private static final boolean VERBOSE = false;
|
||||
|
||||
@@ -25,9 +25,9 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
class UrlConnection extends SynchronousHttpClient {
|
||||
private static final boolean VERBOSE = false;
|
||||
|
||||
@@ -25,8 +25,10 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
@@ -40,6 +40,8 @@ import okhttp3.HttpUrl;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.RecordingHostnameVerifier;
|
||||
import okhttp3.internal.Util;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -48,7 +50,7 @@ import org.junit.runners.model.Statement;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -39,7 +39,7 @@ import okio.Okio;
|
||||
import okio.Source;
|
||||
|
||||
import static okhttp3.internal.platform.Platform.INFO;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
|
||||
/** A basic HTTP/2 server that serves the contents of a local directory. */
|
||||
public final class Http2Server extends Http2Connection.Listener {
|
||||
@@ -24,10 +24,6 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.airlift</groupId>
|
||||
<artifactId>airline</artifactId>
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-urlconnection</artifactId>
|
||||
|
||||
@@ -37,13 +37,13 @@ import okhttp3.internal.Internal;
|
||||
import okhttp3.internal.cache.InternalCache;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@@ -67,7 +67,7 @@ import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.GzipSink;
|
||||
@@ -78,7 +78,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -35,7 +35,7 @@ import okhttp3.ResponseBody;
|
||||
import okhttp3.logging.HttpLoggingInterceptor.Level;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.ByteString;
|
||||
@@ -44,7 +44,7 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@@ -33,6 +33,12 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-urlconnection</artifactId>
|
||||
|
||||
@@ -41,7 +41,7 @@ import okhttp3.internal.platform.Platform;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.BufferedSource;
|
||||
@@ -54,7 +54,7 @@ import org.junit.Test;
|
||||
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.mockwebserver.SocketPolicy.DISCONNECT_AT_END;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -61,12 +61,12 @@ import okhttp3.internal.Version;
|
||||
import okhttp3.internal.http.RecordingProxySelector;
|
||||
import okhttp3.internal.io.InMemoryFileSystem;
|
||||
import okhttp3.mockwebserver.Dispatcher;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.BufferedSource;
|
||||
@@ -83,7 +83,7 @@ import org.junit.rules.Timeout;
|
||||
import static java.net.CookiePolicy.ACCEPT_ORIGINAL_SERVER;
|
||||
import static okhttp3.TestUtil.awaitGarbageCollection;
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.List;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.internal.tls.CertificateChainCleaner;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
import okhttp3.CertificatePinner.Pin;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -26,10 +26,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
|
||||
@@ -22,14 +22,14 @@ import javax.net.ssl.SSLException;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -47,7 +47,7 @@ import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
@@ -62,7 +62,7 @@ import org.junit.Test;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.hamcrest.CoreMatchers.any;
|
||||
import static org.hamcrest.CoreMatchers.either;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
||||
@@ -76,7 +76,7 @@ import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.GzipSink;
|
||||
@@ -102,7 +102,7 @@ import static okhttp3.mockwebserver.SocketPolicy.FAIL_HANDSHAKE;
|
||||
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_INPUT_AT_END;
|
||||
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_OUTPUT_AT_END;
|
||||
import static okhttp3.mockwebserver.SocketPolicy.UPGRADE_TO_SSL_AT_END;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -25,10 +25,10 @@ import javax.net.ssl.SSLSocket;
|
||||
import okhttp3.ConnectionSpec;
|
||||
import okhttp3.TlsVersion;
|
||||
import okhttp3.internal.Internal;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Test;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -39,12 +39,12 @@ import okhttp3.Protocol;
|
||||
import okhttp3.Route;
|
||||
import okhttp3.internal.Util;
|
||||
import okhttp3.internal.http.RecordingProxySelector;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.net.Proxy.NO_PROXY;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
@@ -61,7 +61,7 @@ import okhttp3.mockwebserver.PushPromise;
|
||||
import okhttp3.mockwebserver.QueueDispatcher;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.GzipSink;
|
||||
@@ -79,7 +79,7 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -34,18 +34,18 @@ import okhttp3.RecordingHostnameVerifier;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.internal.platform.Platform;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.internal.platform.PlatformTest.getPlatform;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.newKeyManager;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.newTrustManager;
|
||||
import static okhttp3.tls.internal.TlsUtil.newKeyManager;
|
||||
import static okhttp3.tls.internal.TlsUtil.newTrustManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -33,18 +33,18 @@ import okhttp3.Call;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.internal.platform.PlatformTest.getPlatform;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.newKeyManager;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.newTrustManager;
|
||||
import static okhttp3.tls.internal.TlsUtil.newKeyManager;
|
||||
import static okhttp3.tls.internal.TlsUtil.newTrustManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.SocketPolicy;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.ByteString;
|
||||
import org.junit.After;
|
||||
@@ -49,7 +49,7 @@ import org.junit.Test;
|
||||
|
||||
import static okhttp3.TestUtil.defaultClient;
|
||||
import static okhttp3.TestUtil.repeat;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
5
okhttp-tls/README.md
Normal file
5
okhttp-tls/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
OkHttp TLS
|
||||
==========
|
||||
|
||||
Approachable APIs for using TLS.
|
||||
|
||||
70
okhttp-tls/pom.xml
Normal file
70
okhttp-tls/pom.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>3.11.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<name>OkHttp Transport Layer Security (TLS)</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-testing-support</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<configuration>
|
||||
<links>
|
||||
<link>http://square.github.io/okhttp/javadoc/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Automatic-Module-Name>okhttp3.tls</Automatic-Module-Name>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package okhttp3.mockwebserver;
|
||||
package okhttp3.tls;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package okhttp3.mockwebserver;
|
||||
package okhttp3.tls;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.SecureRandom;
|
||||
@@ -28,8 +28,8 @@ import javax.net.ssl.X509KeyManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.internal.platform.Platform;
|
||||
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.newKeyManager;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.newTrustManager;
|
||||
import static okhttp3.tls.internal.TlsUtil.newKeyManager;
|
||||
import static okhttp3.tls.internal.TlsUtil.newTrustManager;
|
||||
|
||||
/**
|
||||
* Certificates to identify which peers to trust and also to earn the trust of those peers in kind.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package okhttp3.mockwebserver.internal.tls;
|
||||
package okhttp3.tls.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -31,8 +31,8 @@ import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.X509KeyManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.mockwebserver.HeldCertificate;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import okhttp3.tls.TlsNode;
|
||||
|
||||
public final class TlsUtil {
|
||||
public static final char[] password = "password".toCharArray();
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package okhttp3.mockwebserver;
|
||||
package okhttp3.tls;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyFactory;
|
||||
@@ -35,6 +35,12 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>okhttp-tls</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
@@ -20,7 +20,7 @@ import okhttp3.internal.io.InMemoryFileSystem;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.BufferedSource;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -28,7 +28,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static okio.Okio.buffer;
|
||||
import static okio.Okio.source;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -47,7 +47,7 @@ import okhttp3.internal.platform.Platform;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import okhttp3.mockwebserver.TlsNode;
|
||||
import okhttp3.tls.TlsNode;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.GzipSink;
|
||||
@@ -58,7 +58,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static okhttp3.mockwebserver.SocketPolicy.DISCONNECT_AT_END;
|
||||
import static okhttp3.mockwebserver.internal.tls.TlsUtil.localhost;
|
||||
import static okhttp3.tls.internal.TlsUtil.localhost;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
Reference in New Issue
Block a user