ssl pinning android

This commit is contained in:
Diego Mello 2024-04-01 18:22:10 -03:00
parent 5711b2f08a
commit c8f9e841c5
6 changed files with 37 additions and 7 deletions

View File

@ -223,6 +223,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.facebook.soloader:soloader:0.10.4'
implementation("com.facebook.fresco:animated-gif:2.5.0")
implementation "com.facebook.fresco:imagepipeline-okhttp3:3.1.3"
// need this?
// react-native-screens was pointing to a newer version of this lib that is currently not supported in our app

View File

@ -6,7 +6,9 @@ import com.facebook.react.modules.network.NetworkingModule;
import com.facebook.react.modules.network.CustomClientBuilder;
import com.facebook.react.modules.network.ReactCookieJarContainer;
import com.facebook.react.modules.websocket.WebSocketModule;
// import com.facebook.react.modules.fresco.ReactOkHttpNetworkFetcher;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Promise;
@ -34,7 +36,7 @@ import java.util.concurrent.TimeUnit;
import com.RNFetchBlob.RNFetchBlob;
// import com.reactnativecommunity.webview.RNCWebViewManager;
import com.reactnativecommunity.webview.RNCWebViewManager;
import com.dylanvann.fastimage.FastImageOkHttpUrlLoader;
@ -103,11 +105,14 @@ public class SSLPinningModule extends ReactContextBaseJavaModule implements KeyC
// Websocket react-native layer
WebSocketModule.setCustomClientBuilder(new CustomClient());
// Image networking react-native layer
// ReactOkHttpNetworkFetcher.setOkHttpClient(getOkHttpClient());
ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
.newBuilder(this.reactContext, getOkHttpClient())
.build();
Fresco.initialize(this.reactContext, config);
// RNFetchBlob networking layer
// RNFetchBlob.applyCustomOkHttpClient(getOkHttpClient());
RNFetchBlob.applyCustomOkHttpClient(getOkHttpClient());
// RNCWebView onReceivedClientCertRequest
// RNCWebViewManager.setCertificateAlias(data);
RNCWebViewManager.setCertificateAlias(data);
// FastImage Glide network layer
FastImageOkHttpUrlLoader.setOkHttpClient(getOkHttpClient());
// Expo AV network layer

View File

@ -137,7 +137,7 @@
"remove-markdown": "0.3.0",
"reselect": "4.0.0",
"rn-extensions-share": "RocketChat/rn-extensions-share",
"rn-fetch-blob": "0.12.0",
"rn-fetch-blob": "^0.12.0",
"rn-root-view": "RocketChat/rn-root-view",
"semver": "7.3.8",
"transliteration": "2.3.5",

View File

@ -0,0 +1,24 @@
diff --git a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
index 602d51d..920d975 100644
--- a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
+++ b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
@@ -38,7 +38,7 @@ import static com.RNFetchBlob.RNFetchBlobConst.GET_CONTENT_INTENT;
public class RNFetchBlob extends ReactContextBaseJavaModule {
- private final OkHttpClient mClient;
+ static private OkHttpClient mClient;
static ReactApplicationContext RCTContext;
private static LinkedBlockingQueue<Runnable> taskQueue = new LinkedBlockingQueue<>();
@@ -75,6 +75,10 @@ public class RNFetchBlob extends ReactContextBaseJavaModule {
});
}
+ public static void applyCustomOkHttpClient(OkHttpClient client) {
+ mClient = client;
+ }
+
@Override
public String getName() {
return "RNFetchBlob";

View File

@ -17125,7 +17125,7 @@ rn-extensions-share@RocketChat/rn-extensions-share:
version "2.4.1"
resolved "https://codeload.github.com/RocketChat/rn-extensions-share/tar.gz/4d7c0e4c2f300e4fb116af7b7cc0dbbc8169150c"
rn-fetch-blob@0.12.0:
rn-fetch-blob@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/rn-fetch-blob/-/rn-fetch-blob-0.12.0.tgz#ec610d2f9b3f1065556b58ab9c106eeb256f3cba"
integrity sha512-+QnR7AsJ14zqpVVUbzbtAjq0iI8c9tCg49tIoKO2ezjzRunN7YL6zFSFSWZm6d+mE/l9r+OeDM3jmb2tBb2WbA==