RonRadtke / react-native-blob-util

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
773 stars 131 forks source link

java to kotlin change example #350

Open valery-lavrik opened 7 months ago

valery-lavrik commented 7 months ago

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[]{};
                }
        };
RonRadtke commented 7 months ago

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

valery-lavrik commented 7 months ago

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

RonRadtke commented 7 months ago

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.

valery-lavrik commented 7 months ago

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
Bartosz-L commented 6 months ago

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