bitfireat / cert4android Goto Github PK
View Code? Open in Web Editor NEWAndroid service + TrustManager for managing custom certificates in an app-private key store
License: GNU General Public License v3.0
Android service + TrustManager for managing custom certificates in an app-private key store
License: GNU General Public License v3.0
To make the library more stable and future-proof, I'd like to get rid of some legacies like AIDL (#12) or in this case POJO lock/notify:
cert4android/lib/src/main/java/at/bitfire/cert4android/CustomCertManager.kt
Lines 166 to 190 in f167e84
I think a more modern approach would be:
ICustomCertService
should return a CompletableDeferred<Boolean>
instead of taking the IOnCertificateDecision
callbackCustomCertManager
, we could wait for the result like here: https://github.com/bitfireAT/davx5/blob/1430010196a6d0ac4cb109d0d14a329570b3de96/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncAdapterServices.kt#L96-L104CustomCertService.binder.checkTrusted
should create and use the CompletableDeferred<Boolean>
I hope that this will work as I imagine. Can you please give it a try @ArnyminerZ?
The way the module actually defines package names. As stated by Google in Android Developers, the package name should be stated in the build.gradle
file. Updating the build.gradle
file to add the namespace
option fixes the problem:
android {
defaultConfig {
namespace "at.bitfire.cert4android"
}
}
In any case, this change is recommended in AGP 7.3+. So it should be implemented.
We don't need the AIDL interfaces; they are from times when cert4android had to communicate between multiple processes (because DAVx⁵ was split into multiple processes).
AIDL is disabled by default since AGP 8.0 and I think we should get rid of it.
It should be replaced by appropriate inter-thread communication.
I've copied this from the Google Play Console. Not occurring often but we should fix it ;-)
Exception java.lang.IllegalStateException: Already resumed, but proposed with update false
at kotlinx.coroutines.CancellableContinuationImpl.alreadyResumedError (CancellableContinuationImpl.kt:559)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl (CancellableContinuationImpl.kt:524)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default (CancellableContinuationImpl.kt:497)
at kotlinx.coroutines.CancellableContinuationImpl.resumeWith (CancellableContinuationImpl.kt:368)
at at.bitfire.cert4android.UserDecisionRegistry.onUserDecision (UserDecisionRegistry.kt:113)
at at.bitfire.cert4android.TrustCertificateActivity$Model.registerDecision (TrustCertificateActivity.kt:312)
at at.bitfire.cert4android.TrustCertificateActivity$onCreate$2.handleOnBackPressed (TrustCertificateActivity.kt:77)
at androidx.activity.OnBackPressedDispatcher.onBackPressed (OnBackPressedDispatcher.kt:213)
at androidx.activity.ComponentActivity.onBackPressed (ComponentActivity.java:694)
at android.app.Activity.onKeyUp (Activity.java:3940)
at android.view.KeyEvent.dispatch (KeyEvent.java:3143)
at android.app.Activity.dispatchKeyEvent (Activity.java:4286)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent (ComponentActivity.java:126)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent (KeyEventDispatcher.java:86)
at androidx.core.app.ComponentActivity.dispatchKeyEvent (ComponentActivity.java:144)
at com.android.internal.policy.DecorView.dispatchKeyEvent (DecorView.java:415)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent (ViewRootImpl.java:6664)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:6530)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5990)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:6047)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:6013)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:6178)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:6021)
at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:6235)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5994)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:6047)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:6013)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:6021)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5994)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:6047)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:6013)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:6211)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent (ViewRootImpl.java:6391)
at android.view.inputmethod.InputMethodManager$PendingEvent.run (InputMethodManager.java:3667)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback (InputMethodManager.java:3187)
at android.view.inputmethod.InputMethodManager.finishedInputEvent (InputMethodManager.java:3178)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished (InputMethodManager.java:3644)
at android.view.InputEventSender.dispatchInputEventFinished (InputEventSender.java:154)
at android.os.MessageQueue.nativePollOnce
at android.os.MessageQueue.next (MessageQueue.java:335)
at android.os.Looper.loopOnce (Looper.java:185)
at android.os.Looper.loop (Looper.java:359)
at android.app.ActivityThread.main (ActivityThread.java:8127)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:942)
When a certificate becomes invalid over time, users sometimes don't see the certification notification, and then the connections are rejected with time out.
Let's try with one level higher notifications (importance high):
NotificationUtils.createChannels
NotificationCompat.Builder
too, for Android versions that don't have channels yetIs MD5 secure enough to display a fingerprint to let users decide whether the certificate is trusted? Otherwise just keep SHA1
Tracking issue for:
When the timeout ends for accepting a new certificate, if the TrustCertificateActivity
is open, it's never finished, so the Activity just lays there. It should be closed automatically.
Reference: bitfireAT/davx5-ose#411
There's currently just TrustCertificateActivity
in cert4android, so we can migrate it to Jetpack Compose, and see how it goes, before migrating icsx5 and the bigger projects.
Steps:
dataBinding
and enable compose
TrustCertificateActivity
activity_trust_certificate
from layouts.People report that they are now unable to connect DAVx5 to their server in certain certificate use cases. It seems that our handling is correct, and in the past this was wrong. But maybe we can give them an option to accept the certificate anyway?
curl https://mail.elestra.si:2080/
curl: (60) SSL: no alternative certificate subject name matches target host name '[mail.elestra.si](http://mail.elestra.si/)'
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above
Ticket references:
https://bitfire-at.zammad.com/#ticket/zoom/2632
https://bitfire-at.zammad.com/#ticket/zoom/2620
We would have to care less about compile-time settings when this would be a real library. It would be easier to integrate with other projects.
I think of this is a separate library that
can be added as a normal dependency and then be used in other projects
has two components, something like a lib
and and sample-app
directory:
lib
contains the lib and is what is imported when other projects add the dependencysample-app
contains a minimum sample app that also allows to test cert4android in real when debugging (not imported with the dependency)make it a jitpack library
document how to embed the library
separate demo app from lib
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.