owncloud / ios-library

MIT License
77 stars 90 forks source link

NSURLErrorDomain error -1012 #51

Closed marinofaggiana closed 10 years ago

marinofaggiana commented 10 years ago

I have download owncloud iOS library for develop app iOS 7 but this is the first error, i have correctly set username, password and baseurl with https://cloud.xxxx.it/ .... this is the error :

2014-09-01 17:39:13.891 OCLibraryExample[3788:907] Path: https://cloud.xxxxx.it/remote.php/webdav/ 2014-09-01 17:39:13.896 OCLibraryExample[3788:907] headers: { "Accept-Language" = "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5"; Authorization = "Basic bWFyaedrfrrYW5hOmdvbGZtM3VldWdhbWJh"; "User-Agent" = "OCLibraryExample/1.0 (iPhone Simulator; iOS 6.1; Scale/1.00)"; } 2014-09-01 17:39:14.081 OCLibraryExample[3788:907] Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x769e3b0 {NSErrorFailingURLKey=https://cloud.xxxxxx.it/remote.php/webdav/, NSErrorFailingURLStringKey=https://cloud.xxxxxx.it/remote.php/webdav/}

why ???? thanks.

EmrahKK commented 10 years ago

I am getting same error. I am using OCLibraryExample and try to connect over http http://xxx/remote.php/webdav/

and getting

2014-09-03 11:52:09.762 OCLibraryExample[1618:60b] Path: http://xxx/remote.php/webdav/ 2014-09-03 11:52:09.770 OCLibraryExample[1618:60b] headers: { "Accept-Language" = "tr;q=1, en;q=0.9, fr;q=0.8, de;q=0.7, zh-Hans;q=0.6, zh-Hant;q=0.5"; Authorization = "Basic dGVzdDp0ZXN0"; "User-Agent" = "OCLibraryExample/1.0 (iPad; iOS 7.1.2; Scale/2.00)"; } 2014-09-03 11:52:10.120 OCLibraryExample[1618:60b] Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x15e757f0 {NSErrorFailingURLKey=http://xxx/remote.php/webdav/, NSErrorFailingURLStringKey=http://xxx/remote.php/webdav/}

marinofaggiana commented 10 years ago

yes !! and now ?????

javiergonzper commented 10 years ago

Hi,

I tried the example and it works. I just clicked on "list of files" and then "refresh". Could you access to your server via WebDav using the browser? http://xxx/remote.php/webdav/

marinofaggiana commented 10 years ago

Hi, yes, i did list of files and refresh and error ... http://xxx/remote.php/webdav/ via browser is ok ... which are problems of invalid certificates (https) ... ? (with app for iOS its ok (ownCloud), no problem) ...

marinofaggiana commented 10 years ago

p.s. test ownCloud IOS library its all OK !!

javiergonzper commented 10 years ago

Ok, looks like you not control if you are connection to a HTTPS self signed.

@EmrahKK have the solution here: https://github.com/owncloud/ios-library/issues/52

marinofaggiana commented 10 years ago

ok thanks, now look at it, it would be better to write it in the documentation or changing the sample?

marinofaggiana commented 10 years ago

emmmm javiergonzper ... help !! I looked but I do not see how to apply it in the OCCommunication ... :(

javiergonzper commented 10 years ago

Sure, we have to do both :wink:

The fastest way is adding this method on the file OCHTTPRequestOperation.m to overwrite the original

- (instancetype)initWithRequest:(NSURLRequest *)urlRequest {
self = [super initWithRequest:urlRequest];
if (!self) {
    return nil;
}

AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
securityPolicy.allowInvalidCertificates = YES;
[self setSecurityPolicy:securityPolicy];

self.responseSerializer = [AFHTTPResponseSerializer serializer];

return self;

}

marinofaggiana commented 10 years ago

oh !! thanks ... now it works !! maybe when you have time you can think of a solution for the OC Library ? :)

javiergonzper commented 10 years ago

Sure, we will do :wink: