Giter Club home page Giter Club logo

Comments (15)

pp111 avatar pp111 commented on May 25, 2024 1

I am in the same situation, the AndroidClientHandler is not working with PROPFIND and the HttpClientHandler is not working with some certificates. So it is not possible to use this library to access some servers.

from webdavclient.

tipa avatar tipa commented on May 25, 2024 1

@cesarchefinho

var httpHandler = new SocketsHttpHandler();
httpHandler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
httpHandler.Credentials = new NetworkCredential(username, password);
var client = new WebDavClient(new HttpClient(httpHandler, true) { BaseAddress = new Uri(url) });

The issue has also been discussed here

from webdavclient.

skazantsev avatar skazantsev commented on May 25, 2024

After some consideration I decided to not include a workaround into the library since it's a rare case and it should be possible to implement a workaround on the client (hopefully X-HTTP-Method-Override is enough).

Thanks for bringing this up though, this could be helpful for people who encountered the same problem.

from webdavclient.

vitalii-vov avatar vitalii-vov commented on May 25, 2024

@tipa @skazantsev Is there any sample code on how to fix this?

from webdavclient.

vitalii-vov avatar vitalii-vov commented on May 25, 2024

I found a solution to the problem. It is enough to add the HttpClientHandler to the client. I don't know why it works.

var handler = new HttpClientHandler();
//   this line fix Java.Net.ProtocolException: Expected one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH] but was PROPFIND in android
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
HttpClient client = new HttpClient(handler);
// ...
return new WebDavClient(client);

from webdavclient.

tipa avatar tipa commented on May 25, 2024

I found a solution to the problem. It is enough to add the HttpClientHandler to the client. I don't know why it works.

It works because the HttpClientHandler doesn't have the problem that the AndroidClientHandler has, which is used by default on Xamarin.Android.

from webdavclient.

vitalii-vov avatar vitalii-vov commented on May 25, 2024

It would be nice to write about this in the library manual. Since this is not an obvious thing. It took me all day to find a solution. This could save other developers time.

from webdavclient.

TestmanX avatar TestmanX commented on May 25, 2024

Hi everybody, I had to go the opposite way, from HttpClientHandler to AndroidClientHandler because it will keep giving Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED with the Let's Encrypt certificates past 09/30. Using the Android handler enables the use of TLS 1.2 instead of 1.0. So, after the expiration, it will be common to find this error in the wild. I'm still stuck trying to overcome the Expected one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH] but was PROPFIND error. What would be the suggested override for PROPFIND using X-HTTP-Method-Override?

from webdavclient.

tipa avatar tipa commented on May 25, 2024

So it is not possible to use this library to access some servers.

@pp111 it is possible, but you need to use HttpClientHandler instead of AndroidClientHandler

from webdavclient.

pp111 avatar pp111 commented on May 25, 2024

If I use HttpClientHandler I get the exception

Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED

The certificate is fine, but needs TLS 1.2 which seems to be not supported with HttpClientHandler on Android (on Windows it works fine).

Using AndroidClientHandler the certificate validation works fine, but it fails because of the PROPFIND issue.

So, if I am not missing something, none of the two handlers are working with TLS1.2 servers on Android.

from webdavclient.

tipa avatar tipa commented on May 25, 2024

You can ignore that certificate check like this:

var httpHandler = new HttpClientHandler()
{
    Credentials = new NetworkCredential(usernam, password),
    ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true,
};

from webdavclient.

pp111 avatar pp111 commented on May 25, 2024

Yes, I think this is the only option although it might be potentially unsafe.

from webdavclient.

tipa avatar tipa commented on May 25, 2024

The HttpClientHandler stopped working with .net 6 Android. It is now required to opt-out of the AndroidMessageHandler on a project-level. I reported this issue the Microsoft here: xamarin/xamarin-android#7291

from webdavclient.

cesarchefinho avatar cesarchefinho commented on May 25, 2024

The HttpClientHandler stopped working with .net 6 Android. It is now required to opt-out of the AndroidMessageHandler on a project-level. I reported this issue the Microsoft here: xamarin/xamarin-android#7291

can you post here an step by step how-to make work with android ? I try all things and cannot resolve the propfind exception...

thanks

from webdavclient.

tipa avatar tipa commented on May 25, 2024

After some consideration I decided to not include a workaround into the library since it's a rare case and it should be possible to implement a workaround on the client (hopefully X-HTTP-Method-Override is enough).

@skazantsev I am still forced to use a SocketsHttpHandler in order to send PROPFIND requests on Android, but this comes at other disadvantages (exceptions, performance). AndroidMessageHandler is just the recommended http handler to be used on Android. Can you expand on your comment how one can use X-HTTP-Method-Override with the current implementation to overcome this problem?

from webdavclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.