0

Im working on the port from Xamarin (Android) to Maui Net7 (Android).

I have a HTTPClient for Webdav Calls. Under Xamarin i use the ServerCertificateCustomValidationCallback but under Maui Net7 this callback is never called!

httpHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => {                 return true;};'

In the first step i get the error that Propfind Http method not supported, i use the
<UseNativeHttpHandler>false</UseNativeHttpHandler> in the project to fix this.

After i test the SSL, i get an SSL error and the callback ServerCertificateCustomValidationCallback is not called under Maui Net7 (Android).

I need to support self signed certificates, how can I do that under Net7 Maui (Android)?

Many thanks in advance

Matze
  • 101
  • 1
  • 6
  • Use the method described here: https://stackoverflow.com/questions/12553277/allowing-untrusted-ssl-certificates-with-httpclient#18232008 Do you need to trust all certificates or just self signed ones? Or only from a specific domain? Also, it seems like using WebRequestHandler would be better from this post. I cannot verify that all of these work on android, but they probably do. – SupaMaggie70 b Mar 08 '23 at 17:49
  • Never mind, from the documentation it says “ Provides desktop-specific features not available to Windows Store apps or other environments.” – SupaMaggie70 b Mar 08 '23 at 17:51
  • The documentation on MSDN seems a little lacking in terms of version support. MAUI doesn’t show up like Xamarin or Net Standard. It is difficult for me to find an alternative right now, I would recommend using a separate library. – SupaMaggie70 b Mar 08 '23 at 17:56
  • You can refer to this case which is about [trusting additional CAs and make use of the Android certificate store in a net6 MAUI solution](https://stackoverflow.com/questions/72276421/trust-additional-cas-and-make-use-of-the-android-certificate-store-in-a-net6-mau). – Liyun Zhang - MSFT Mar 10 '23 at 09:04
  • Thanks for the tip, https://stackoverflow.com/questions/72276421/trust-additional-cas-and-make-use-of-the-android-certificate-store-in-a-net6-mau now it works when I add the CA certificate in Android,then the callback ServerCertificateCustomValidationCallback is also executed. However, the certificate must be installed in Android! WebRequestHandler can not be used in Android. Is there also a way to trust all server certificates? – Matze Mar 10 '23 at 15:12
  • It seems there is no a such way. The android has the limit about trusting certificates. – Liyun Zhang - MSFT Mar 13 '23 at 09:45
  • Thank you for your help, i work 2 weeks on this problem under Maui, on Xamarin works all perfect. I hope the maui team fix all the issues soon. Thank you Liyun Zhang! – Matze Mar 13 '23 at 20:10
  • You can post an new issue on the github. – Liyun Zhang - MSFT Mar 15 '23 at 08:17

0 Answers0