react-native-blob-util icon indicating copy to clipboard operation
react-native-blob-util copied to clipboard

java to kotlin change example

Open valery-lavrik opened this issue 1 year ago • 5 comments

Now react-native has been translated into kotlin, but this example is written in java. Please fix it on kotlin

        ReactNativeBlobUtilUtils.sharedTrustManager = x509TrustManager = new X509TrustManager() {
                @Override
                public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
                }

                @Override
                public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
                }

                @Override
                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                    return new java.security.cert.X509Certificate[]{};
                }
        };

valery-lavrik avatar Apr 11 '24 12:04 valery-lavrik

@valery-lavrik how do you get to the conclusion this lib was rewritten to kotlin? The codebase for android is still in java.

RonRadtke avatar Apr 14 '24 18:04 RonRadtke

@RonRadtke The fact is that the MainApplication.kt file has already been transferred to kotlin.

valery-lavrik avatar Apr 15 '24 05:04 valery-lavrik

Ah sorry, I missed that you were talking about react-native itself and not the lib. A kotlin example would be great you're absolutely right there.

RonRadtke avatar Apr 17 '24 06:04 RonRadtke

my knowledge of java and kotlin is very poor, but I tried to do it myself. Please tell me, did I do everything right?

import com.ReactNativeBlobUtil.ReactNativeBlobUtilUtils
import java.security.cert.X509Certificate
import javax.net.ssl.X509TrustManager
import java.security.cert.CertificateException

.........
    ReactNativeBlobUtilUtils.sharedTrustManager = object : X509TrustManager {
        override fun checkClientTrusted(chain: Array<java.security.cert.X509Certificate>, authType: String) {}
        override fun checkServerTrusted(chain: Array<java.security.cert.X509Certificate>, authType: String) {}
        override fun getAcceptedIssuers(): Array<java.security.cert.X509Certificate> { return arrayOf() }
    } as X509TrustManager


valery-lavrik avatar Apr 17 '24 10:04 valery-lavrik

my knowledge of java and kotlin is very poor, but I tried to do it myself. Please tell me, did I do everything right?

import com.ReactNativeBlobUtil.ReactNativeBlobUtilUtils
import java.security.cert.X509Certificate
import javax.net.ssl.X509TrustManager
import java.security.cert.CertificateException

.........
    ReactNativeBlobUtilUtils.sharedTrustManager = object : X509TrustManager {
        override fun checkClientTrusted(chain: Array<java.security.cert.X509Certificate>, authType: String) {}
        override fun checkServerTrusted(chain: Array<java.security.cert.X509Certificate>, authType: String) {}
        override fun getAcceptedIssuers(): Array<java.security.cert.X509Certificate> { return arrayOf() }
    } as X509TrustManager

It's working but I think there is no need for

as X509TrustManager

But correct me if I'm wrong

Bartosz-L avatar May 21 '24 08:05 Bartosz-L