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()
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?
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 :
I installed the AFNetworking 2.6. version via Cocoapods to have access to the AFNetworking library The request looks like this:
The output of the error message is:
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?