Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java to kotlin change example #350

Open
valery-lavrik opened this issue Apr 11, 2024 · 5 comments
Open

java to kotlin change example #350

valery-lavrik opened this issue Apr 11, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@valery-lavrik
Copy link

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
Copy link
Owner

@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
Copy link
Author

valery-lavrik commented Apr 15, 2024

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

@RonRadtke
Copy link
Owner

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 RonRadtke added the documentation Improvements or additions to documentation label Apr 17, 2024
@valery-lavrik
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants