GCD没有得到的网页内容得到的字符串部署在互联网上



我正在后台线程模块获得当前时间显示在网页上为10-06-2014 16:19:11。当涉及到执行时,没有数据被获取。你能告诉我如何创建inputStream和阅读web内容吗?假设https链接正常工作给出的消息是:此服务器的证书无效。您想要连接到服务器吗?

下面是我的留言

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>}`
下面是我的代码

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);
        }
    });

});

你的URL无法解析,所以你最好检查两次。

查看其他服务

最新更新