1

I'm trying to perform SSL pinning in React Native. The main issue is: On the Android side, we aim to transfer the key and SSL pinning activation status obtained from remoteConfig to the native side using the bridge. However, SSL pinning doesn't seem to function on Android, whereas it works on the iOS side. I assume that it should be implemented in the onCreate method within the MainApplication file. Although I managed to retrieve and utilize the values from RemoteConfig on the native side, SSL pinning still doesn't work. Do you have any suggested approaches?

I called and used the remote config on the native side, but ssl pinning did not work. I also call MainApplication onCreate and MainActivity onCreate.

`public class SSLPinningFactory implements OkHttpClientFactory { private static String hostname = "*.asfaf.com";

private String pinningKey;

public SSLPinningFactory(String pinningKey) {
    this.pinningKey = pinningKey;
}

public OkHttpClient createNewNetworkModuleClient() {
    String key = "sha256/" + pinningKey;

    CertificatePinner certificatePinner = new CertificatePinner.Builder()
            .add(hostname, key)
            .build();

    OkHttpClient.Builder client = new OkHttpClient.Builder()
            .connectTimeout(0, TimeUnit.MILLISECONDS)
            .readTimeout(0, TimeUnit.MILLISECONDS)
            .writeTimeout(0, TimeUnit.MILLISECONDS)
            .cookieJar(new ReactCookieJarContainer())
            .certificatePinner(certificatePinner);

    return client.certificatePinner(certificatePinner).build();
}

}`

0 Answers0