I am working on the background thread module of getting the current time being displayed on the webpage as 10-06-2014 16:19:11. When it comes to the execution, no data is get. Would you please tell me how to create the inputStream and read the web content ? Assume that https link is working Given the message is : The certificate for this server is invalid.Would you like to connect to the server anyway?,
The below is my message
2014-06-10 16:46:16.292 marker[2724:7707] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9807)
2014-06-10 16:46:16.296 marker[2724:60b] Error = Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.cei-hk.net” which could put your confidential information at risk.
" UserInfo=0x146be370 {NSErrorFailingURLStringKey=https://dc02.cei-hk.net:8081/GetTime.aspx, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,
NSErrorFailingURLKey=https://dc02.csd-hk.net:8081/GetTime.aspx, NSLocalizedDescript`
ion=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.cei-hk.net” which could put your confidential information at risk., NSUnderlyingError=0x14582870 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.csd-hk.net” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x14675820>}`
The below is my code
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *jsonURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://dc02.csd-hk.net:8081/GetTime.aspx",nil]];
NSError *error = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:jsonURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0 ];
NSData *responsedata = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
NSString* jsonData = [[NSString alloc] initWithData:responsedata encoding:NSUTF8StringEncoding];
// NSString *json = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
if( jsonData.length > 0 )
{
NSLog(@"Text=%@", jsonData);
[ToastView showToastInParentView:self.view withText:jsonData withDuaration:5.0];
}
else
{
NSLog(@"Error = %@", error);
}
});
});