Skip to content

Commit 955dcc9

Browse files
authored
Remove SSL Pinning (APPS-1821) (#222)
1 parent cdc0a0c commit 955dcc9

File tree

5 files changed

+18
-53
lines changed

5 files changed

+18
-53
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
55
### Added
66
### Changed
77
### Removed
8+
* core: SSL Pinning has been removed
9+
* ui: Datatrans SSL Pinning has been deactivated
810
### Fixed
911

1012
## [0.79.0]

core/src/main/java/io/snabble/sdk/Config.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package io.snabble.sdk
22

33
import android.content.Context
4-
import com.google.gson.*
4+
import com.google.gson.JsonDeserializationContext
5+
import com.google.gson.JsonDeserializer
6+
import com.google.gson.JsonElement
7+
import com.google.gson.JsonNull
8+
import com.google.gson.JsonPrimitive
9+
import com.google.gson.JsonSerializationContext
10+
import com.google.gson.JsonSerializer
511
import io.snabble.sdk.utils.Dispatch
612
import io.snabble.sdk.utils.GsonHolder
713
import io.snabble.sdk.utils.Logger
814
import okhttp3.Interceptor
915
import java.io.File
10-
import java.lang.Exception
1116
import java.lang.reflect.Type
1217
import java.util.concurrent.TimeUnit
1318

@@ -96,10 +101,6 @@ data class Config (
96101
@JvmField
97102
var maxShoppingCartAge: Long = TimeUnit.HOURS.toMillis(4),
98103

99-
/** If set to true, disables certificate pinning. Not recommended for production! */
100-
@JvmField
101-
var disableCertificatePinning: Boolean = false,
102-
103104
/** SQL queries that will get executed in order on the product database. */
104105
@JvmField
105106
var initialSQL: List<String> = emptyList(),

core/src/main/java/io/snabble/sdk/OkHttpClientFactory.kt

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,20 @@ import io.snabble.sdk.auth.useragent.UserAgentInterceptor
66
import io.snabble.sdk.utils.LetsEncryptCertHelper
77
import io.snabble.sdk.utils.Logger
88
import okhttp3.Cache
9-
import okhttp3.CertificatePinner
109
import okhttp3.OkHttpClient
1110
import java.util.concurrent.TimeUnit
1211

1312
@RestrictTo(RestrictTo.Scope.LIBRARY)
1413
internal object OkHttpClientFactory {
15-
private val PINS = arrayOf(
16-
"sha256/YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", // Let's Encrypt X3 cross-signed
17-
"sha256/sRHdihwgkaib1P1gxX8HFszlD+7/gTfNvuAybgLPNis=", // Let's Encrypt X4 cross-signed
18-
"sha256/J2/oqMTsdhFWW/n85tys6b4yDBtb6idZayIEBx7QTxA=", // Let's Encrypt E1
19-
"sha256/vZNucrIS7293MQLGt304+UKXMi78JTlrwyeUIuDIknA=", // Let's Encrypt E2
20-
"sha256/jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=", // Let's Encrypt R3 cross-signed
21-
"sha256/5VReIRNHJBiRxVSgOTTN6bdJZkpZ0m1hX+WPd5kPLQM=", // Let's Encrypt R4 cross-signed
22-
// backup CAs
23-
"sha256/C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=", // ISRG Root X1
24-
"sha256/lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU=", // AddTrust External Root
25-
"sha256/r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=", // DigiCert Global Root
26-
"sha256/i7WTqTvh0OioIruIfFR4kMPnBqrS2rdiVPl/s2uC/CY=", // DigiCert Global Root G2
27-
"sha256/WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=", // DigiCert HA Root
28-
"sha256/h6801m+z8v3zbgkRHpq6L29Esgfzhj89C1SyUCOQmqU=", // GeoTrust Global
29-
"sha256/q5hJUnat8eyv8o81xTBIeB5cFxjaucjmelBPT2pRMo8=", // GeoTrust PCA G3 Root
30-
"sha256/47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", // GeoTrust PCA G4
31-
"sha256/SQVGZiOrQXi+kqxcvWWE96HhfydlLVqFr4lQTqI5qqo=" // GeoTrust PCA
32-
)
3314

3415
@RestrictTo(RestrictTo.Scope.LIBRARY)
35-
internal fun createOkHttpClient(application: Application): OkHttpClient {
36-
val builder = OkHttpClient.Builder()
37-
builder.cache(Cache(application.cacheDir, 10 * 1024 * 1024))
38-
builder.retryOnConnectionFailure(true)
39-
builder.pingInterval(5, TimeUnit.SECONDS) // workaround for https://github.com/square/okhttp/issues/3146
40-
builder.addInterceptor(OkHttpLogger { message: String? ->
41-
Logger.i(message)
42-
})
43-
Snabble.config.networkInterceptor?.let {
44-
builder.addNetworkInterceptor(it)
45-
}
46-
builder.addInterceptor(UserAgentInterceptor(application))
47-
if (!Snabble.config.disableCertificatePinning) {
48-
val environments = Environment.values()
49-
builder.certificatePinner(CertificatePinner.Builder().apply {
50-
PINS.forEach { pin ->
51-
environments.forEach { env ->
52-
add(env.wildcardUrl, pin)
53-
}
54-
}
55-
}.build())
56-
}
57-
LetsEncryptCertHelper.addLetsEncryptCertificatesForMarshmallowOrEarlier(builder)
58-
return builder.build()
59-
}
16+
internal fun createOkHttpClient(application: Application): OkHttpClient = OkHttpClient.Builder()
17+
.cache(Cache(application.cacheDir, 10 * 1024 * 1024))
18+
.retryOnConnectionFailure(true)
19+
.pingInterval(5, TimeUnit.SECONDS) // workaround for https://github.com/square/okhttp/issues/3146
20+
.addInterceptor(OkHttpLogger { message: String? -> Logger.i(message) })
21+
.addInterceptor(UserAgentInterceptor(application))
22+
.apply { Snabble.config.networkInterceptor?.let { addNetworkInterceptor(it) } }
23+
.apply { LetsEncryptCertHelper.addLetsEncryptCertificatesForMarshmallowOrEarlier(this) }
24+
.build()
6025
}

core/src/main/java/io/snabble/sdk/SnabbleInitializer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class SnabbleInitializer : Initializer<Snabble> {
4040
generateSearchIndex = properties.getBoolean("generateSearchIndex", generateSearchIndex)
4141
maxProductDatabaseAge = properties.getLong("maxProductDatabaseAge", maxProductDatabaseAge)
4242
maxShoppingCartAge = properties.getLong("maxShoppingCartAge", maxShoppingCartAge)
43-
disableCertificatePinning = properties.getBoolean("disableCertificatePinning", disableCertificatePinning)
4443
vibrateToConfirmCartFilled = properties.getBoolean("vibrateToConfirmCartFilled", vibrateToConfirmCartFilled)
4544
loadActiveShops = properties.getBoolean("loadActiveShops", loadActiveShops)
4645
checkInRadius = properties.getFloat("checkInRadius", checkInRadius)
@@ -81,7 +80,6 @@ class SnabbleInitializer : Initializer<Snabble> {
8180
generateSearchIndex = getBoolean("snabble_generate_search_index", generateSearchIndex)
8281
maxProductDatabaseAge = getLong("snabble_max_product_database_age", maxProductDatabaseAge)
8382
maxShoppingCartAge = getLong("snabble_max_shopping_cart_age", maxShoppingCartAge)
84-
disableCertificatePinning = getBoolean("snabble_disable_certificate_pinning")
8583
vibrateToConfirmCartFilled = getBoolean("snabble_vibrate_to_confirm_cart_filled", vibrateToConfirmCartFilled)
8684
loadActiveShops = getBoolean("snabble_load_active_shops", loadActiveShops)
8785
checkInRadius = getFloat("snabble_check_in_radius", checkInRadius)

ui/src/main/java/io/snabble/sdk/ui/payment/creditcard/datatrans/ui/DatatransViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ internal class DatatransViewModel(
8686
}
8787
options.appCallbackScheme = "snabble"
8888
options.isTesting = isTesting
89-
options.useCertificatePinning = true
9089
}
9190

9291
fun errorHandled() {

0 commit comments

Comments
 (0)