Certificate pinning not working

config.setPinnedServerCertificate(pinnedServerCert) is giving me following error

java.lang.NoSuchMethodError: No static method verifyAsIpAddress(Ljava/lang/String;)Z in class Lokhttp3/internal/Util; or its super classes (declaration of ‘okhttp3.internal.Util’ appears in /data/app/com.metispro.quanticpos-Pzcp2nCL2_svKEMsmIadzw==/base.apk!classes3.dex)
at okhttp3.internal.tls.CustomHostnameVerifier.verify(CustomHostnameVerifier.java:68)
at okhttp3.internal.tls.CustomHostnameVerifier.verify(CustomHostnameVerifier.java:60)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:357)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:310)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:178)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:236)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:109)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:77)
at okhttp3.internal.connection.Transmitter.newExchange$okhttp(Transmitter.kt:162)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:35)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

I little more information would be really useful. Which of our products are you using? What version are you using? Can we see the code that is failing?

It looks to me as if you have a wrong version of okhttp bound into your app.

and one more thing,

configurations.all {
resolutionStrategy.force ‘com.squareup.okhttp3:logging-interceptor:3.9.1’
resolutionStrategy.force ‘com.squareup.okhttp3:okhttp:3.9.1’
}
if i force the version it worked but is there any better solution from your side?

Still not very sura I understandwhat kind of help do you expect…

@Pratik_Chatterjee, until we have some idea of what product and what version of that product you are using, we can’t be of much help.

I don’t know if there are any other ways beside syncing the OKHTTP version to fix this problem quickly. CBL-Android is using OKHTTP v.3.14.7 but ideally CBL Android shouldn’t use the internal OKHTTP API.

I tried to downgrade the OK Http version by fixing dependency resolution strategy but that stopped many other libraries to work as they were compatible with the latet version of OKHTTP3 one of them being the fmou firebase crashlytics and some others.