Skip to content
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

NullPointer Exception #4

Open
genie137 opened this issue Mar 21, 2018 · 4 comments
Open

NullPointer Exception #4

genie137 opened this issue Mar 21, 2018 · 4 comments

Comments

@genie137
Copy link

genie137 commented Mar 21, 2018

I just got a nullpointerexception while getting the key. It seems to make the key go all 0`s.... Any hints?

java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes()' on a null object reference
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at android.util.Base64.decode(Base64.java:118)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at com.github.tntkhang.realmencryptionhelper.RealmEncryptionHelper.getSecretKey(RealmEncryptionHelper.java:120)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at com.github.tntkhang.realmencryptionhelper.RealmEncryptionHelper.getEncryptKey(RealmEncryptionHelper.java:107)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at <PACKAGE>datamanagement.Connector.openSyncedRealm(Connector.java:66)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at <PACKAGE>datamanagement.Connector.access$100(Connector.java:14)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at <PACKAGE>datamanagement.Connector$1.onSuccess(Connector.java:36)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at <PACKAGE>datamanagement.Connector$1.onSuccess(Connector.java:30)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at io.realm.SyncUser$Request$3.run(SyncUser.java:695)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at android.os.Looper.loop(Looper.java:154)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6692)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
03-21 11:16:50.837 562-562/<PACKAGE> W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
03-21 11:16:50.837 562-562/<PACKAGE> I/tntkhang: getSecretKey string: null
03-21 11:16:50.837 562-562/<PACKAGE> I/tntkhang: getSecretKey key: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
03-21 11:16:50.837 562-562/<PACKAGE> I/tntkhang: encryptedKey: 64 -- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
@genie137
Copy link
Author

genie137 commented Mar 21, 2018

Hmm, when i delete the data and cache of the app. it generates a non-0 key. but still now throws another error:

03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.security.cert.Certificate java.security.KeyStore$PrivateKeyEntry.getCertificate()' on a null object reference
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at com.github.tntkhang.realmencryptionhelper.RealmEncryptionHelper.rsaEncrypt(RealmEncryptionHelper.java:154)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at com.github.tntkhang.realmencryptionhelper.RealmEncryptionHelper.generate64BitSecretKey(RealmEncryptionHelper.java:139)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at com.github.tntkhang.realmencryptionhelper.RealmEncryptionHelper.getEncryptKey(RealmEncryptionHelper.java:104)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at <PACKAGE>.datamanagement.Connector.openSyncedRealm(Connector.java:66)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at <PACKAGE>.datamanagement.Connector.access$100(Connector.java:14)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at <PACKAGE>.datamanagement.Connector$1.onSuccess(Connector.java:36)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at <PACKAGE>.datamanagement.Connector$1.onSuccess(Connector.java:30)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at io.realm.SyncUser$Request$3.run(SyncUser.java:695)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at android.os.Looper.loop(Looper.java:154)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6692)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
03-21 11:24:58.927 3756-3756/<PACKAGE>. W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
03-21 11:24:58.928 3756-3756/<PACKAGE>. I/tntkhang: generate64BitSecretKey key: [-45, -28, -97, 40, 38, 22, -28, 103, -45, 97, -60, 57, -84, -77, -36, 123, -37, 113, -5, -78, -5, -36, -23, 52, -15, -60, -11, -35, 85, 37, 5, 44, -88, 6, -40, -42, -17, -15, 5, 110, -2, -67, -98, 127, -107, -92, -86, 120, -97, 29, -103, -27, -69, 50, -119, 48, 55, -7, 33, -110, -12, -45, 126, 34]
03-21 11:24:58.928 3756-3756/<PACKAGE>. I/tntkhang: encryptedKey: 64 -- [-45, -28, -97, 40, 38, 22, -28, 103, -45, 97, -60, 57, -84, -77, -36, 123, -37, 113, -5, -78, -5, -36, -23, 52, -15, -60, -11, -35, 85, 37, 5, 44, -88, 6, -40, -42, -17, -15, 5, 110, -2, -67, -98, 127, -107, -92, -86, 120, -97, 29, -103, -27, -69, 50, -119, 48, 55, -7, 33, -110, -12, -45, 126, 34]

@tntkhang
Copy link
Owner

I will try to reproduce and investigate this bug. Thanks

@genie137
Copy link
Author

Do you have an ETA on the fix?

@tntkhang
Copy link
Owner

Still not found the solution :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants