flymzero / webdav_client

A dart WebDAV client library
https://pub.dev/packages/webdav_client
BSD 3-Clause "New" or "Revised" License
55 stars 34 forks source link

Connect to server using self signed certificate? #8

Closed stcojo closed 3 years ago

stcojo commented 3 years ago

Hi, thanks for a great library! Does the library have the option to connect to a WebDAV server which uses a self signed certificate?

All I get is a timeout error. I am using it like this:

var client = webdav.Client( uri: "https://someserver/", c: webdav.WdDio(debug: true ), auth: webdav.BasicAuth(user: "user", pwd: "pass"), );

flymzero commented 3 years ago

Since the network request uses dio (header reason). You can refer to the documentation.

The following code has not been tested. 😄


var dio = webdav.WdDio(debug: true);

// The underlying layer is httpClient String PEM = 'XXXXX'; // certificate content (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) { client.badCertificateCallback = (X509Certificate cert, String host, int port) { if (cert.pem == PEM) { // Verify the certificate return true; } return false; }; };

var client = webdav.Client( uri: "https://someserver/", c: dio, auth: webdav.BasicAuth(user: "user", pwd: "pass"), );

stcojo commented 3 years ago

this works, thanks a lot