Skip to content

Commit

Permalink
Merge pull request #537 from dropbox/jfein/remove-cert-pinning
Browse files Browse the repository at this point in the history
Remove cert pinning from the SDK
  • Loading branch information
joshafeinberg authored Apr 29, 2024
2 parents 0f765cb + fa4c4c1 commit d5e243d
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 1,870 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ buildscript {
}

dependencies {
classpath files('gradle/dropbox-pem-converter-plugin')
classpath(dropboxJavaSdkLibs.android.gradle.plugin)
classpath(dropboxJavaSdkLibs.kotlin.gradle.plugin)
classpath("com.dropbox.gradle.plugins:stone-java-gradle-plugin")
Expand Down
13 changes: 2 additions & 11 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,6 @@ public final class com/dropbox/core/http/OkHttpRequestor$AsyncCallback : com/squ
public fun onResponse (Lcom/squareup/okhttp/Response;)V
}

public class com/dropbox/core/http/SSLConfig {
public fun <init> ()V
public static fun apply (Ljavax/net/ssl/HttpsURLConnection;)V
public static fun getSSLSocketFactory ()Ljavax/net/ssl/SSLSocketFactory;
public static fun getTrustManager ()Ljavax/net/ssl/X509TrustManager;
}

public final class com/dropbox/core/http/SSLConfig$LoadException : java/lang/Exception {
public fun <init> (Ljava/lang/String;Ljava/lang/Throwable;)V
}

public class com/dropbox/core/http/StandardHttpRequestor : com/dropbox/core/http/HttpRequestor {
public static final field INSTANCE Lcom/dropbox/core/http/StandardHttpRequestor;
public fun <init> (Lcom/dropbox/core/http/StandardHttpRequestor$Config;)V
Expand All @@ -553,6 +542,7 @@ public final class com/dropbox/core/http/StandardHttpRequestor$Config {
public fun getConnectTimeoutMillis ()J
public fun getProxy ()Ljava/net/Proxy;
public fun getReadTimeoutMillis ()J
public fun getSslSocketFactory ()Ljavax/net/ssl/SSLSocketFactory;
}

public final class com/dropbox/core/http/StandardHttpRequestor$Config$Builder {
Expand All @@ -562,6 +552,7 @@ public final class com/dropbox/core/http/StandardHttpRequestor$Config$Builder {
public fun withNoReadTimeout ()Lcom/dropbox/core/http/StandardHttpRequestor$Config$Builder;
public fun withProxy (Ljava/net/Proxy;)Lcom/dropbox/core/http/StandardHttpRequestor$Config$Builder;
public fun withReadTimeout (JLjava/util/concurrent/TimeUnit;)Lcom/dropbox/core/http/StandardHttpRequestor$Config$Builder;
public fun withSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;)Lcom/dropbox/core/http/StandardHttpRequestor$Config$Builder;
}

public class com/dropbox/core/json/JsonArrayReader : com/dropbox/core/json/JsonReader {
Expand Down
20 changes: 0 additions & 20 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,6 @@ configurations {
withoutOsgi.extendsFrom api
}

processResources { task ->
filesMatching('**/*.crt') { fcd ->
def inputstream = fcd.open()
def certDatas = com.dropbox.maven.pem_converter.PemLoader.load(
new InputStreamReader(inputstream, "UTF-8")
)
inputstream.close()

def crtPath = fcd.getPath()
def rawPath = crtPath.substring(0, crtPath.length() - 4) + ".raw"
def rawFile = new File(task.getDestinationDir(), rawPath);
rawFile.getParentFile().mkdirs();
def out = new DataOutputStream(new FileOutputStream(rawFile))
com.dropbox.maven.pem_converter.RawLoader.store(certDatas, out)
out.close()

fcd.exclude()
}
}

tasks.named("compileJava", JavaCompile) {
options.compilerArgs << '-Xlint:all'
options.warnings = true
Expand Down
15 changes: 1 addition & 14 deletions core/src/main/java/com/dropbox/core/http/OkHttp3Requestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public static OkHttpClient.Builder defaultOkHttpClientBuilder() {
return new OkHttpClient.Builder()
.connectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
.readTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
.writeTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
// enables certificate pinning
.sslSocketFactory(SSLConfig.getSSLSocketFactory(), SSLConfig.getTrustManager());
.writeTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}

private final OkHttpClient client;
Expand All @@ -68,17 +66,6 @@ public static OkHttpClient.Builder defaultOkHttpClientBuilder() {
* .build();
* </pre>
*
* <p>
* If you don't use {@link #defaultOkHttpClient()} or {@link #defaultOkHttpClientBuilder()},
* make sure to use Dropbox's hardened SSL settings from {@link SSLConfig}:
* </p>
*
* <pre>
* OkHttpClient client = OkHttpClient.Builder()
* ...
* .sslSocketFactory(SSLConfig.getSSLSocketFactory(), SSLConfig.getTrustManager())
* .build();
* </pre>
*/
public OkHttp3Requestor(OkHttpClient client) {
if (client == null) throw new NullPointerException("client");
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/com/dropbox/core/http/OkHttpRequestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public static OkHttpClient defaultOkHttpClient() {
client.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
client.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
client.setWriteTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
// enables certificate pinning
client.setSslSocketFactory(SSLConfig.getSSLSocketFactory());
return client;
}

Expand All @@ -61,14 +59,6 @@ public static OkHttpClient defaultOkHttpClient() {
* HttpRequestor requestor = new OkHttpRequestor(client);
* </pre>
*
* <p>
* If you don't use {@link #defaultOkHttpClient()}, make sure to use Dropbox's
* hardened SSL settings from {@link SSLConfig}:
* </p>
*
* <pre>
* client.setSslSocketFactory(SSLConfig.getSSLSocketFactory())
* </pre>
*/
public OkHttpRequestor(OkHttpClient client) {
if (client == null) throw new NullPointerException("client");
Expand Down
Loading

0 comments on commit d5e243d

Please sign in to comment.