-
Notifications
You must be signed in to change notification settings - Fork 538
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
Error making https call to local development environment with SocketsHttpHandler #6048
Comments
@JamesNK This is most likely an issue with the BCL, Xamarin.Android doesn't customize the way System.Net.Security works, MAUI is even less likely a factor. @steveisok, mind taking a look and forwarding to whoever can investigate the issue on your side? Thanks! |
I think the issue related to this work is here dotnet/runtime#45741 |
Yes, this is a runtime issue. The Android implementation of SocketsHttpHandler does not yet support the use of self-signed certs. The reason being is that we made the decision to keep the native integration JNI only and Android does not support creating classes from there. Therefore, we aren't able to create a custom |
I did a few experiments with adding the aspnetcore cert as trusted to the Android app via https://developer.android.com/training/articles/security-config#TrustingDebugCa since that should allow the APIs we're using to trust the certificate. For some reason, it works fine if I do it in Android Studio with a Java app but not if I translate the Java code to a Xamarin.Android app in VS (i.e. using the Java APIs, not .NET HttpClient). I get the same @grendello any idea how I could debug why this is not working? |
I started a discussion topic on how to connect from Android emulators to a local ASP.NET Web API running on Windows: dotnet/maui#8131 Please check that out and let us know if you have any feedback on any of the solutions presented. |
@steveisok: I'm catching up to this comment way too late:
I'm do not understand what you mean. dotnet/runtime could provide some |
As far as I know we enabled this in .NET 8 with dotnet/runtime#77386 exactly like you described by shipping a custom .java TrustManager. |
Yes, when I wrote this, I said "we can't" from the perspective of we weren't going to ship custom java classes from runtime. In .NET 8, we relaxed that position, and this issue can probably be closed. |
This sounds fixed, closing. |
Steps to Reproduce
I tried out
SocketsHttpHandler
+ TLS in .NET 6 preview 5 in an Android Emulator. I found it successfully made HTTP request to a public website that was using TLS with a valid certificate, but failed to call a local website that is using the ASP.NET Core developer certificate.Error:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Usually to get around this problem on other .NET platforms you would configure the handler to ignore certificate warnings.
Configuring the HTTP handler to ignore certificate errors didn't help on Xamarin/Maui:
That doesn't change the result on Xamarin/MAUI.
Expected Behavior
Can successfully make call to local development site that is using ASP.NET Core developer certificate
Actual Behavior
Error above
Version Information
Log File
The text was updated successfully, but these errors were encountered: