Skip to content
This repository was archived by the owner on Feb 5, 2026. It is now read-only.
This repository was archived by the owner on Feb 5, 2026. It is now read-only.

Cannot upload file using SSL even though I even accept invalid SSL certificates #130

@slashburn

Description

@slashburn

Hi there,

I would like to add SSL support for my app. For testing purposes, I use an self generated Let's encrypt SSL certificate from my web host to protect my my URL. Now I would like to upload a file using the HTTPS instead of the HTTP protocol.

As shown in the owncloud example project (AppDelegate), I configured my OCCommunication object to accept invalid SSL certificates. I also set a the "Allow Arbitrary load flag" in my own project (not the owncloud project). The configuration looks like this :

import AFNetworking

let ocCommunication = OCCommunication()
ocCommunication.setCredentialsWithUser(userName, andPassword: password)

let securityPolicy  = AFSecurityPolicy.defaultPolicy()
securityPolicy.allowInvalidCertificates = true;
ocCommunication.securityPolicy = securityPolicy

I installed the AFNetworking 2.6. version via Cocoapods to have access to the AFNetworking library
The request looks like this:

var operation : NSOperation? = nil
operation = ocCommunication.uploadFile(folderURL.path, toDestiny: fileURL, onCommunication: ocCommunication,
            progressUpload: ({ (bytesWrote, totalBytesWrote, totalBytesExpectedToWrite) in
                //this method is not called
            }),
            successRequest: ({(response, redirectedServer) in
                // success case ...
            }),
            failureRequest: ({ (response, redirectedServer, error) in
                //this is where the error occurs
                print(response)
                print(error)
            }),
            failureBeforeRequest: ({ error in
               //not called
            }),
            shouldExecuteAsBackgroundTaskWithExpirationHandler: ({
                operation?.cancel()
            }))
operation?.start()

The output of the error message is:

<NSHTTPURLResponse: 0x130c44fb0> { URL: https:/[myURL.de]/remote.php/webdav/4690FDD4-D350-4513-9797-451A76FD7591.zip } { status code: 401, headers {
"Accept-Language" = "de-DE;q=1, en-DE;q=0.9";
Authorization = "Basic abcdefghi";
"Content-Length" = 2680387;
"User-Agent" = "MyApp/1.0 (iPhone; iOS 9.3.1; Scale/2.00)";
} }
Error Domain=com.owncloud Code=401 "(null)"

My request is somehow unauthorized. If I try to upload a file using curl with HTTPS, it works perfectly fine. I also see the green HTTPS lock when I open the site in the browser window.
Does anyone have an idea what I'm doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions