braintree / braintree_android

Braintree SDK for Android
https://developer.paypal.com/braintree/docs/start/hello-client/android/v4
MIT License
407 stars 233 forks source link

NullPointerException: com.braintreepayments.api.TLSCertificatePinning.getCertInputStream (TLSCertificatePinning.java:719) #1020

Closed kimrtaylor closed 3 months ago

kimrtaylor commented 4 months ago

Braintree SDK Version

4.45.0

Environment

Production

Android Version & Device

Multiple

Braintree dependencies

com.braintreepayments.api:card:4.45.0

Describe the bug

We're seeing a new crash affecting some of our customers, since updating from 4.44.0 to 4.45.0. It occurs during initialisation of BraintreeClient

To reproduce

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.nio.charset.Charset)' on a null object reference
com.braintreepayments.api.TLSCertificatePinning.getCertInputStream (TLSCertificatePinning.java:719)
com.braintreepayments.api.BraintreeHttpClient$Companion.createDefaultHttpClient (BraintreeHttpClient.java:178)
com.braintreepayments.api.BraintreeHttpClient$Companion.access$createDefaultHttpClient (BraintreeHttpClient.java:172)
com.braintreepayments.api.BraintreeHttpClient.<init> (BraintreeHttpClient.kt:12)
com.braintreepayments.api.AnalyticsClient.<init> (AnalyticsClient.kt:25)
com.braintreepayments.api.BraintreeClientParams.<init> (BraintreeClientParams.kt:14)
com.braintreepayments.api.BraintreeClientParams.<init> (BraintreeClientParams.kt:22)
com.braintreepayments.api.BraintreeClient.<init> (BraintreeClient.kt:70)
com.braintreepayments.api.BraintreeClient.<init> (BraintreeClient.kt:80)

Expected behavior

exception handled

Screenshots

No response

sshropshire commented 4 months ago

Hey @kimrtaylor thanks for using the Braintree SDK for Android. I'd like to help pinpoint the issue and hopefully find a fix.

One thing that seems odd to me is the stack trace mentions the exception originating form TLSCertificatePinning.java in our SDK. TLSCetificatePinning in our project is written in Kotlin.

Can you help me to answer a few questions:

sshropshire commented 4 months ago

Hey @kimrtaylor @nick-titov-sw checking in. Is there any additional information available for this crash?

nick-titov-sw commented 4 months ago

Hey @sshropshire, thanks for such a quick response! We are not able to reproduce the issue ourselves, most of the crashes happened on Samsung devicese and the rest on Oppo and Google Pixel, Android versions 13 and 14. Its a native Android application. Thanks a lot for checking!

sshropshire commented 4 months ago

Thanks @nick-titov-sw. It's interesting the portion of the code that throws the NPE is virtually the same for TLSCertificatePinning.kt in v4.44.0. We did update the SDK's pinned certificates, but we only changed the string contents of the CERTIFICATES property. Does your app have any similar crashes with the 4.44.0 version?

nick-titov-sw commented 3 months ago

@sshropshire seems like we never had it before, it's a new one for 4.45.0.

sshropshire commented 3 months ago

@nick-titov-sw going to try this to see if it helps resolve: https://github.com/braintree/braintree_android/pull/1036.

sshropshire commented 3 months ago

@all we've provided a potential fix for this issue in our latest 4.48.0 version. Please upgrade and feel free to re-open this issue if the crashes persist.