skjiisa / WebDAV-Swift

WebDAV communication library for Swift with caching and thumbnail support
BSD 2-Clause "Simplified" License
65 stars 17 forks source link

SSL Error occurred on Synology #46

Open cdebaixo opened 7 months ago

cdebaixo commented 7 months ago

I have installed webDAV in my iOS app so that I can take advantage of the listFiles function it supplies. I am using the following code to achieve this:

public struct SimpleAccount: WebDAVAccount {
    public var username: String?
    public var baseURL: String?
}

    let username = "userName"
    let password = "password"
    let webDav = WebDAV()
    let baseURL = "http://ServerName:5005/"
    let path = "serverPath"
    let account = SimpleAccount(username: username, baseURL: baseURL)
    webDav.listFiles(atPath: path, account: account, password: password, caching: .requestEvenIfCached) { files, error in
        if let files = files {
            print(files)
        }
        if let error = error {
            print(error)
        }
    }

but I am getting errors. The first error is "An SSL error has occurred and a secure connection to the server cannot be made". I have tried with https 5006 also without success. Is the problem with Synology or am I missing something in my code? Your help would be much appreciated.

isaced commented 4 months ago

I also encountered the same problem, the reason is that this library will force the use of HTTPS, so the server in the local LAN cannot connect.

https://github.com/skjiisa/WebDAV-Swift/blob/0be9d19396c7b1f200edd9e45003f3237090462e/Sources/WebDAV/Account.swift#L23-L41

This fork may be helpful:

https://github.com/oxtoacart/WebDAV-Swift/commit/162de94dc29bb0802030eff4a9057223a1e2a563#diff-d21258d70a476a92ed2f95967877933b1801725aa44dba10958cccfae5729cecR27-R35