appmattus / certificatetransparency

Certificate transparency for Android and JVM
Apache License 2.0
142 stars 29 forks source link

Required method checkServerTrusted(X509Certificate[], String, String, String) missing error in Release Mode #123

Closed UmerTaptap closed 1 month ago

UmerTaptap commented 1 month ago

Application Class:

` class MyApplication : Application() { override fun onCreate() { super.onCreate()

    installCertificateTransparencyProvider {
        // Setup a logger
        logger = BasicAndroidCTLogger(BuildConfig.DEBUG)

        // Setup disk cache
        diskCache = AndroidDiskCache(applicationContext)

// +"abc.com" +"*.abc.com" } } }

class CustomHurlStackCT : HurlStack() { override fun createConnection(url: URL): HttpURLConnection { val connection = super.createConnection(url) if (connection is HttpsURLConnection) {

        connection.hostnameVerifier = certificateTransparencyHostnameVerifier(connection.hostnameVerifier){
            println("Fail on error: ${this.failOnError}")
        }
    }
    return connection
}

}

private fun makeNetworkRequest(url: String): CompletableFuture<Map<Boolean, String>> { val future = CompletableFuture<Map<Boolean, String>>()

    val requestQueue: RequestQueue = Volley.newRequestQueue(this, CustomHurlStack())

    val stringRequest = object : StringRequest(Method.GET, url,
        Response.Listener<String> { response ->
            // Log the response for debugging
            future.complete(mapOf(true to response))
        },
        Response.ErrorListener { error ->
            future.complete(mapOf(false to (error.message ?: "Unknown error")))
        }) {
        override fun getHeaders(): MutableMap<String, String> {
            val headers = mutableMapOf<String, String>()
            return headers
        }
    }

    requestQueue.add(stringRequest)
    return future
}}

`

dominikgold commented 1 month ago

The consumer-proguard-rules are outdated as of right now. Add this to your own proguard rules for now and it'll work:

-keep class com.appmattus.certificatetransparency.internal.verifier.CertificateTransparencyTrustManagerBasic { *; }
-keep class com.appmattus.certificatetransparency.internal.verifier.CertificateTransparencyTrustManagerExtended { *; }
UmerTaptap commented 1 month ago

Thanks, its worked