Comments (15)
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.
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.
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.
@tipa @skazantsev Is there any sample code on how to fix this?
from webdavclient.
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.
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.
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.
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.
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.
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.
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.
Yes, I think this is the only option although it might be potentially unsafe.
from webdavclient.
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.
The
HttpClientHandler
stopped working with .net 6 Android. It is now required to opt-out of theAndroidMessageHandler
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.
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)
- implementation of HTTP SEARCH method HOT 3
- implementation of HTTP SEARCH method
- How to disable SSL certificate validation? HOT 3
- Get folder URI by fileid property
- Implement advanced search
- Is it possible to create directory? HOT 1
- Directory tree with MKCOL
- Retrieving folders and files in an arabic language is not correct
- Download large files HOT 1
- How to sent data with mkcol?
- Invalid XML in WebDav server responses do not result in a usable exception
- Webdav restart while uploading file. Webdav upload error (async upload, largest file, parallel request)
- Set lastmodified date
- 207 Multi-Status response not parsed correctly
- "Operation is not supported on this platform" in Blazor
- Retrieve file on remote server HOT 1
- Can we integrate it with .net + vue.js ?
- LastModifiedDate UTC?
- ReadStream not passing the Cancellation Token HOT 1
- Broken pipe error and Header lost in .net6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webdavclient.