-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Null Pointer Exception During Certificate Pinning (v. 4.4.1) #5895
Comments
Do you have a test case? It should be set whenever the OkHttpClient is constructed. Do you have any code that is copying an existing OkHttpClient with some changes e.g. |
I am using deprecated sslSocketFactory method. But I believe that shouldn't have been a problem. It should have created CertificateChainCleaner object. This is the method we use to add SSL config. |
When I use
|
If you can make a single main method that reproduces it with a test url it will be a lot easier to debug. We should be cutting 4.5 soon, so the easier you can make it to repro, the quicker you can get a fix. |
After doing some adjustment, I found this statement hidden in logs
Where TLSSocketFactoryCompat is same as #2372 (comment) Using the SocketFactory method with TrustManager as parameter fixes the issue. |
1 last question though. What is the minimum supported API for android for 4.x? |
Thanks. Can improve this behaviour so I'll keep this open. |
@rahul-narkhede https://square.github.io/okhttp/security/ Android 5.0+ (API level 21+) and on Java 8+. |
You shouldn't need any special code for that yourself. It should be all automatically set on any supported platform. |
The logic around initialising OkHttpClient is quite awkward. I think we probably need to centralise some of the logic around building the sslSocketFactory, x509TrustManager, certificateChainCleaner, routeDatabase into the OkHttpClient constructor. And make setting a cleartext only connectionSpecs to clear out all other fields. |
Related #5930 shows that we call certificatePinner.withCertificateChainCleaner with a null certificateChainCleaner |
When creating a certificate pinned connection using OkHttp 4.4.1, we face a Nul Pointer Exception at the following line
https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/internal/connection/RealConnection.kt#L393
Bellow is the stack trace
How should we create a CertificatePinner with certificateCleaner? Or should the code use
?.
operator at the above line rather than!!
The text was updated successfully, but these errors were encountered: