3

This is the code in android java. what would be its equivalent in react-native? stack over flow would not allow me to post mostly code. so this is just useless detail. my question is already over.

        String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);tmf.init(keystore);

        KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");

        kmf.init(keystore, "PASSWORD".toCharArray());

        TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return new java.security.cert.X509Certificate[] {};
            }

            public void checkClientTrusted(X509Certificate[] chain,
                                           String authType) throws CertificateException {
            }

            public void checkServerTrusted(X509Certificate[] chain,
                                           String authType) throws CertificateException {
            }
        } };
        final SSLContext sc = SSLContext.getInstance("TLSv1.2");
        sc.init(kmf.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());
        final SSLSocketFactory socketFactory = sc.getSocketFactory();
        HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
        urlConnection.setSSLSocketFactory(sc.getSocketFactory());
Waheed Akhter
  • 347
  • 2
  • 13
  • Just try using a trusted certificate for your development environment. please see https://stackoverflow.com/questions/32892161/ignore-errors-for-self-signed-ssl-certs-using-the-fetch-api-in-a-reactnative-app/36368360#36368360 – Mohsin Khan Oct 18 '17 at 06:38

0 Answers0