NullPointerException on Certificate.getPublicKey
See original GitHub issueUsing 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:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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
@kibotu the context shouldn’t be a problem as we internally use the application context whatever you pass.