react-native-blob-util
react-native-blob-util copied to clipboard
java to kotlin change example
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 how do you get to the conclusion this lib was rewritten to kotlin? The codebase for android is still in java.
@RonRadtke The fact is that the MainApplication.kt file has already been transferred to kotlin.
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.
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
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