question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException on Certificate.getPublicKey

See original GitHub issue

Using 1.2.2; haven’t reproduced this consistently but have a few reports of it in our logs (a bit messy due to retracing):

Caused by SecureStorageException: Attempt to invoke virtual method 'java.security.PublicKey java.security.cert.Certificate.getPublicKey()' on a null object reference
       at de.adorsys.android.securestoragelibrary.KeystoreTool.java.lang.String encryptMessage(android.content.Context,java.lang.String)(KeystoreTool.java:67)
                                                               void generateKeyPair(android.content.Context)
                                                               boolean keyPairExists()
       at de.adorsys.android.securestoragelibrary.SecurePreferences.void removeSecureValue(android.content.Context,java.lang.String)(SecurePreferences.java:13)
                                                                    void setValue(android.content.Context,java.lang.String,java.lang.String)
       at my.app.modules.SecurePrefsEditor.putString(SecurePrefsEditor.java:15)
       at my.app.modules.AuthModule$authUpdater$1$2.call(AuthModule.java:25)
       at my.app.modules.AuthModule$authUpdater$1$2.call(AuthModule.java)
       at io.reactivex.internal.operators.completable.CompletableFromCallable.void subscribeActual(io.reactivex.CompletableObserver)(CompletableFromCallable.java:9)
       at io.reactivex.Completable.io.reactivex.Completable defer(java.util.concurrent.Callable)(Completable.java:14)
                                   io.reactivex.Completable doOnComplete(io.reactivex.functions.Action)
                                   io.reactivex.Completable doOnError(io.reactivex.functions.Consumer)
                                   io.reactivex.Completable doOnLifecycle(io.reactivex.functions.Consumer,io.reactivex.functions.Consumer,io.reactivex.functions.Action,io.reactivex.functions.Action,io.reactivex.functions.Action,io.reactivex.functions.Action)
                                   io.reactivex.Completable observeOn(io.reactivex.Scheduler)
                                   io.reactivex.Completable onErrorComplete(io.reactivex.functions.Predicate)
                                   io.reactivex.disposables.Disposable subscribe(io.reactivex.functions.Action,io.reactivex.functions.Consumer)
                                   void subscribe(io.reactivex.CompletableObserver)
                                   java.lang.NullPointerException toNpe(java.lang.Throwable)
                                   io.reactivex.Single toSingleDefault(java.lang.Object)
       at io.reactivex.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:2)
       at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:9)
       at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)

Caused by SecureStorageException: Attempt to invoke virtual method 'java.security.PublicKey java.security.cert.Certificate.getPublicKey()' on a null object reference
       at de.adorsys.android.securestoragelibrary.KeystoreTool.java.security.PublicKey getPublicKey(android.content.Context)(KeystoreTool.java:45)
       at de.adorsys.android.securestoragelibrary.KeystoreTool.java.lang.String encryptMessage(android.content.Context,java.lang.String)(KeystoreTool.java:19)
                                                               void generateKeyPair(android.content.Context)
                                                               boolean keyPairExists()
       at de.adorsys.android.securestoragelibrary.SecurePreferences.void removeSecureValue(android.content.Context,java.lang.String)(SecurePreferences.java:13)
                                                                    void setValue(android.content.Context,java.lang.String,java.lang.String)
       at my.app.modules.SecurePrefsEditor.putString(SecurePrefsEditor.java:15)
       at my.app.modules.AuthModule$authUpdater$1$2.call(AuthModule.java:25)
       at my.app.modules.AuthModule$authUpdater$1$2.call(AuthModule.java)
       at io.reactivex.internal.operators.completable.CompletableFromCallable.void subscribeActual(io.reactivex.CompletableObserver)(CompletableFromCallable.java:9)
       at io.reactivex.Completable.io.reactivex.Completable defer(java.util.concurrent.Callable)(Completable.java:14)
                                   io.reactivex.Completable doOnComplete(io.reactivex.functions.Action)
                                   io.reactivex.Completable doOnError(io.reactivex.functions.Consumer)
                                   io.reactivex.Completable doOnLifecycle(io.reactivex.functions.Consumer,io.reactivex.functions.Consumer,io.reactivex.functions.Action,io.reactivex.functions.Action,io.reactivex.functions.Action,io.reactivex.functions.Action)
                                   io.reactivex.Completable observeOn(io.reactivex.Scheduler)
                                   io.reactivex.Completable onErrorComplete(io.reactivex.functions.Predicate)
                                   io.reactivex.disposables.Disposable subscribe(io.reactivex.functions.Action,io.reactivex.functions.Consumer)
                                   void subscribe(io.reactivex.CompletableObserver)
                                   java.lang.NullPointerException toNpe(java.lang.Throwable)
                                   io.reactivex.Single toSingleDefault(java.lang.Object)
       at io.reactivex.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:2)
       at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:9)
       at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
drilonrecicacommented, Jan 23, 2020

Version 1.2.4 is out now. The bug should not reappear. I have tested on ,multiple devices and emulator with different API levels and different installation configurations and cannot reproduce the bug with the logic of v.1.2.4

Thank you all for the contributions to SecureStorage

1reaction
luckyhandlercommented, Nov 2, 2019

@kibotu the context shouldn’t be a problem as we internally use the application context whatever you pass.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error while retrieving the X509 certificate from keystore
But I often get a null pointer exception while retrieving the private key that used to sign the certificate. It sometimes works and...
Read more >
java.security.cert.Certificate.getPublicKey java code examples
Tests whether given certificate contains public key or not. * * @param key Public key which we are looking for. * @param certs...
Read more >
2713718 - Public key fingerprint : java.lang.NullPointerException
NullPointerException - SSO Certificate - Wrong format. Symptom. After a system copy or new installation of NetWeaver Java, where Sybase Database is being...
Read more >
src/main/java/org/conscrypt/TrustedCertificateStore.java
return cert;. } private File fileForAlias(String alias) {. if (alias == null) {. throw new NullPointerException("alias == null");. }.
Read more >
web.mit.edu/ghudson/dev/openfire/src/java/org/jive...
The new certificate together with its private * key are stored in the specified key ... getPublicKey(); String signatureAlgorithm = "DSA".equals(pubKey.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found