braintree_android icon indicating copy to clipboard operation
braintree_android copied to clipboard

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

Open kimrtaylor opened this issue 1 year ago • 6 comments

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

kimrtaylor avatar Jun 03 '24 11:06 kimrtaylor

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:

  • Have you been able to reproduce the issue?
  • Is your app native Android or React Native?
  • Is there any additional information you can provide about the devices that experience this issue (e.g. Android version, Device Manufacturer / Model)?

sshropshire avatar Jun 04 '24 15:06 sshropshire

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

sshropshire avatar Jun 06 '24 15:06 sshropshire

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!

nick-titov-sw avatar Jun 07 '24 08:06 nick-titov-sw

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?

sshropshire avatar Jun 07 '24 15:06 sshropshire

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

nick-titov-sw avatar Jun 10 '24 08:06 nick-titov-sw

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

sshropshire avatar Jun 11 '24 16:06 sshropshire

@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.

sshropshire avatar Jul 02 '24 18:07 sshropshire