Why can Android Keystore not load public key - android-keystore

Why does AndroidKeystore can not load public key certificate?
I am trying to load public key from Android Keystore. But on some devices the public key can not be loaded with the following exception.
Can someone pls explain me why this situation happens?
The error happes mainly on Samsung, Lenovo, Huawei and LG devices with OS version 4+, 5+, 6+ and 7+.
Stacktrace:
Caused by java.security.UnrecoverableKeyException: Failed to obtain X.509 form of public key
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePublicKeyFromKeystore(AndroidKeyStoreProvider.java:223)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreKeyPairFromKeystore(AndroidKeyStoreProvider.java:252)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePrivateKeyFromKeystore(AndroidKeyStoreProvider.java:263)
at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:93)
at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:372)
at java.security.KeyStore.getEntry(KeyStore.java:645)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6322)
at android.app.ActivityThread.access$1800(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1862)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7230)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by android.security.KeyStoreException: OK
at android.security.KeyStore.getKeyStoreException(KeyStore.java:913)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePublicKeyFromKeystore(AndroidKeyStoreProvider.java:223)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreKeyPairFromKeystore(AndroidKeyStoreProvider.java:252)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePrivateKeyFromKeystore(AndroidKeyStoreProvider.java:263)
at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:93)
at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:372)
at java.security.KeyStore.getEntry(KeyStore.java:645)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6322)
at android.app.ActivityThread.access$1800(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1862)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7230)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Related

CryptoException while decrypting in AEM

we are facing CryptoException while decrypting the text in AEM 6.0 version. Actually one of our environment is having this issue. we dont have this issue in other environments. This issue is specific to only one environment. Literally we tried all the options.
Tried options:-
Deleted /etc/key folder in publish server and restarted Adobe Granite Crypto Bundle and restarted pub server too. But nothing is helped and still facing the same error.
Below is complete error message
Caused by: com.adobe.granite.crypto.CryptoException: Cannot convert byte data
at com.adobe.granite.crypto.internal.CryptoSupportImpl.unprotect(CryptoSupportImpl.java:160)
at com.pearson.aem.aemcore.hybris.services.CommerceServiceImpl.getExternalUser(CommerceServiceImpl.java:326)
... 136 common frames omitted
Caused by: com.adobe.granite.crypto.CryptoException: Failed decrypting cipher text
at com.adobe.granite.crypto.internal.CryptoSupportImpl.decrypt(CryptoSupportImpl.java:96)
at com.adobe.granite.crypto.internal.CryptoSupportImpl.unprotect(CryptoSupportImpl.java:157)
... 137 common frames omitted
Caused by: com.rsa.jsafe.JSAFE_PaddingException: Invalid padding.
at com.rsa.jsafe.JSAFE_SymmetricCipher.decryptFinal(Unknown Source)
at com.adobe.granite.crypto.internal.jsafe.JSafeCryptoSupport.getPlainText(JSafeCryptoSupport.java:326)
at com.adobe.granite.crypto.internal.jsafe.JSafeCryptoSupport.getPlainText(JSafeCryptoSupport.java:308)
at com.adobe.granite.crypto.internal.CryptoSupportImpl.decrypt(CryptoSupportImpl.java:94)
... 138 common frames omitted
Is there any config which we should cross verify?

My Android Thing Raspberry Pi is throwing a javax.net.ssl.SSLException when sending request to Firebase Storage

I'm trying to connect my Raspberry Pi using Android Thing to Firebase Storage. I keep getting the attached exception. The Storage Rules are completely public no auth needed. Has anyone else received this error and found a workaround?
javax.net.ssl.SSLException: Write error: ssl=0x95683f00: I/O error during system call, Broken pipe
at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:824)
at com.android.okhttp.okio.Okio$1.write(Okio.java:76)
at com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
at com.android.okhttp.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
at com.android.okhttp.okio.RealBufferedSink.writeUtf8(RealBufferedSink.java:58)
at com.android.okhttp.internal.http.HttpConnection.writeRequest(HttpConnection.java:172)
at com.android.okhttp.internal.http.HttpTransport.writeRequestHeaders(HttpTransport.java:76)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:265)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:521)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
at brv.b(:com.google.android.gms.DynamiteModulesC:1386)
at brv.a(:com.google.android.gms.DynamiteModulesC:269)
at brp.onTransact(:com.google.android.gms.DynamiteModulesC:53)
at android.os.Binder.transact(Binder.java:499)
at com.google.android.gms.internal.zzbrc$zza$zza.zzjN(Unknown Source)
at com.google.android.gms.internal.zzbrf.zza(Unknown Source)
at com.google.android.gms.internal.zzbqw.zza(Unknown Source)
at com.google.android.gms.internal.zzbqw.zzd(Unknown Source)
at com.google.firebase.storage.UploadTask.zzb(Unknown Source)
at com.google.firebase.storage.UploadTask.zzaba(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
A few things to check:
1) Make sure that you have network (you likely already do since you're trying to reach Firebase) e.g. 'ifconfig'
2) Make sure that DNS is working e.g. 'ping ...' something
3) Check system time to see if it's synced to current rather than 1970 e.g. 'date'; you can manually set it current as a workaround
If for any of the above reasons that time is not set properly, your SSL cert probably won't work.
See working code in the Doorbell sample here: https://github.com/androidthings/doorbell

Azure Mobile Service: Unable to load the specified metadata resource

I published my Azure Mobile Service and suddenly I got this error. I use a code first approach and I have not changed my models.
"message": "An error has occurred.",
"exceptionMessage": "Unable to load the specified metadata resource.",
"exceptionType": "System.Data.Entity.Core.MetadataException",
"stackTrace": " at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)\r\n
I m using EF 6.1.1 and my connection string is defined for the System.Data.SqlClientProvider.
It works fine when I run locally against my MSSQLLocalDB.
Anyone knows why EF attempts to load a Metadata even if I am using a code first approach? What should I do to troubleshoot the issue?
I found it, it was my connection string which was modified when the code was built in release environment. This issue was caused by a refactory.

Error when trying to create a new JBOSS OpenShift project

I am trying to have a play around with openshift, but am running into a config issue at the first hurdle.
i have RedHatJBOSS Developer Studio 8.0.0 installed, and have the JBOSS Integration and SOA Development Plugin installed.
I also have an openshift user account and can login just fine to their website.
Basically, when I select the create openshift project from the JBoss central page, and enter my valid openshift credentials and pres next, it tries to connect and immediately throws an error stating an SSL handshake exception occurred (details below).
I am a bit lost if I am honest; is there something I need to install?
I am using JRE 7 in case that is significant
com.openshift.client.OpenShiftEndpointException: Could not request https://openshift.redhat.com/broker/rest/api: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.openshift.internal.client.RestService.request(RestService.java:120)
at com.openshift.internal.client.RestService.request(RestService.java:92)
at com.openshift.internal.client.AbstractOpenShiftConnectionFactory.getConnection(AbstractOpenShiftConnectionFactory.java:36)
at com.openshift.client.OpenShiftConnectionFactory.getConnection(OpenShiftConnectionFactory.java:198)
at com.openshift.client.OpenShiftConnectionFactory.getConnection(OpenShiftConnectionFactory.java:158)
at com.openshift.client.OpenShiftConnectionFactory.getConnection(OpenShiftConnectionFactory.java:114)
at com.openshift.client.OpenShiftConnectionFactory.getConnection(OpenShiftConnectionFactory.java:103)
at org.jboss.tools.openshift.express.internal.core.connection.Connection.createUser(Connection.java:229)
at org.jboss.tools.openshift.express.internal.core.connection.Connection.connect(Connection.java:205)
at org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizardPageModel.connect(ConnectionWizardPageModel.java:247)
at org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizardPage$ConnectJob.run(ConnectionWizardPage.java:479)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: com.openshift.internal.client.httpclient.HttpClientException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:201)
at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:161)
at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:140)
at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.get(UrlConnectionHttpClient.java:99)
at com.openshift.internal.client.RestService.request(RestService.java:160)
at com.openshift.internal.client.RestService.request(RestService.java:107)
... 11 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:85)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:541)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1686)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1684)
at java.security.AccessController.doPrivileged(AccessController.java:330)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1682)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1255)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:479)
at com.ibm.net.ssl.www2.protocol.https.b.getResponseCode(b.java:40)
at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:184)
... 16 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.ibm.jsse2.j.a(j.java:33)
at com.ibm.jsse2.j.a(j.java:31)
at com.ibm.jsse2.qc.b(qc.java:190)
at com.ibm.jsse2.qc.a(qc.java:456)
at com.ibm.jsse2.qc.h(qc.java:352)
at com.ibm.jsse2.qc.a(qc.java:523)
at com.ibm.jsse2.qc.startHandshake(qc.java:730)
at com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:70)
at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:9)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1311)
at com.ibm.net.ssl.www2.protocol.https.b.getInputStream(b.java:89)
at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:157)
... 15 more
This looks very weird, I didnt spot this so far. SSL handshake is failing for some unknown reason.
What is the exact version of your JDK7?
What is your OS?
Cheers
Andre

Android Emulator 4.2 (API Level 17) "Unfortunately camera has stopped" When try to access camera from the main menu

I'm using Android 4.2 (API Level 17) emulator.
Whenever I clicked on the Camera, I got the following error message :
Unfortunately, camera has stopped
These are the logcat errors :
E/CameraService(40): CameraService::connect X (pid 862) rejected (invalid cameraId 0).
E/CameraHolder(862): fail to connect Camera
E/CameraHolder(862): java.lang.RuntimeException: Fail to connect to camera service
E/CameraHolder(862): at android.hardware.Camera.native_setup(Native Method)
E/CameraHolder(862): at android.hardware.Camera.<init>(Camera.java:340)
E/CameraHolder(862): at android.hardware.Camera.open(Camera.java:302)
E/CameraHolder(862): at com.android.camera.CameraHolder.open(CameraHolder.java:131)
E/CameraHolder(862): at com.android.camera.Util.openCamera(Util.java:267)
E/CameraHolder(862): at com.android.camera.Camera$4.run(Camera.java:1100)
E/AndroidRuntime(862): java.lang.RuntimeException: openCamera failed
E/AndroidRuntime(862): at com.android.camera.Util.openCamera(Util.java:272)
E/AndroidRuntime(862): at com.android.camera.Camera$4.run(Camera.java:1100)
E/AndroidRuntime(862): Caused by: com.android.camera.CameraHardwareException: java.lang.RuntimeException: Fail to connect to camera service
E/AndroidRuntime(862): at com.android.camera.CameraHolder.open(CameraHolder.java:135)
E/AndroidRuntime(862): at com.android.camera.Util.openCamera(Util.java:267)
E/AndroidRuntime(862): Caused by: java.lang.RuntimeException: Fail to connect to camera service
E/AndroidRuntime(862): at android.hardware.Camera.native_setup(Native Method)
E/AndroidRuntime(862): at android.hardware.Camera.<init>(Camera.java:340)
E/AndroidRuntime(862): at android.hardware.Camera.open(Camera.java:302)
E/AndroidRuntime(862): at com.android.camera.CameraHolder.open(CameraHolder.java:131)
I tried various solutions. But no luck :(
No one has given a working solution for this problem so far. Please give me a hint
Webcam : Dell Integrated webcam
OS : windows 8 Professional 64 bit version
Cheers !!!
You probably don't care anymore but this was one of the first ones i got when i googled the same problem so in case anyone else runs into this i found that my problem was that i had selected no camera in the AVD (seems to be default)