-
Notifications
You must be signed in to change notification settings - Fork 167
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
[Bug]: CertPathValidatorException on Android 6. #2865
Comments
Does this error happen if you change the HttpClientHandler implementation from Android to Managed? |
In the meanwhile I can reproduce the issue on for API 23(Android 6) but not on another APIs (I tried API 30). As originally reported by the user. |
@nirinchev Yes, the error is still happening after changing both "HttpClient implementation" and "SSL/TLS implementation" to managed. I checked the .csproj because sometimes it doesn't update properly, but it looks right. <AndroidHttpClientHandlerType>Managed (HttpClientHandler)</AndroidHttpClientHandlerType>
<AndroidTlsProvider>Managed TLS 1.0</AndroidTlsProvider> |
This is an issue due to older versions of Android not trusting the new root certificate of Let's Encrypt. There are no clear workaround currently. We have two options for solving this: Expose a way to provide custom HttpClientHandlerCurrently we construct an http client with the default handler. We can expose a configuration mechanism for users to provide their custom http client handlers. MultitargetingWhen we start multitargeting the Realm assembly, we can provide an android implementation that trusts the ISRG root with the following code: private const string ISRGRoot =
@"MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs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sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=";
var handler = new AndroidClientHandler();
if (handler.TrustedCerts == null)
{
handler.TrustedCerts = new List<Certificate>();
}
var factory = CertificateFactory.GetInstance("X.509");
var cert = factory.GenerateCertificate(new MemoryStream(Convert.FromBase64String(ISRGRoot)));
handler.TrustedCerts.Add(cert); We can probably expose the config option first and then provide the default implementation. |
@nirinchev I suspected this was the issue. After manually installing Let's Encrypt ISRG Root X1 certificate on an Android 6 emulator, Realm is working fine. Of course this is not a workaround, we cannot ask users to manually install a certificate. Will the custom HttpClientHandler property be hotfixed? And I think Realm should alert about this issue somewhere, right now it's not possible to release an app that supports Android 7 or below with MongoDB Realm. |
@luccasclezar the SRE team has deployed a new certificate that is cross-signed by the DST Root X3, which should be accepted by older Android devices. As an aside, we also added a way to configure the |
Thank you @nirinchev! I can confirm the issue is fixed without the need to configure a custom HttpClientHandler. |
➤ Andrea Catalini commented: A solution was implemented and merged in main. |
What happened?
MongoDB Realm does not connect on Android 6, any Android version after that is working correctly.
The line
Realms.Sync.User user = await App.MongoApp.LogInAsync(credentials);
throws ajava.security.cert.CertPathValidatorException
.I don't know if this issue is occurring on real devices or only on emulators, I don't have any Android 6 device to test.
Repro steps
Just try to use MongoDB Realm on Android 6.
androidmtest.zip
Version
10.10.0
What SDK flavour are you using?
MongoDB Realm (i.e. Sync, auth, functions)
What type of application is this?
Xamarin
Client OS and version
Android 6
Code snippets
No response
Stacktrace of the exception/crash you're getting
Relevant log output
No response
The text was updated successfully, but these errors were encountered: