Objective C Web服务请求适用于http://但不适用于https://

时间:2014-03-27 18:18:26

标签: objective-c web-services https

有什么建议吗?该代码与http完美配合,但不适用于https://。我想知道它是不是这个港口。证书有效。我得到一台假装成另一台服务器的服务器"错误。

NSString *post=[[NSString alloc] initWithFormat:@"strEmail=%@&strPassword=%@", [self.txtUsername text], [self.txtPassword text]];
    NSLog(@"PostData%@", post);

//      NSURL *url= [NSURL URLWithString:@"http://dipinkrishna.com/jsonlogin.php"]; // does work
        NSURL *url= [NSURL URLWithString:@"https://dev.myrdcm.com/felipe.asmx?op=GetSignIn”];// does not work
        NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
        NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
        [request setHTTPMethod:@"POST"];
        [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
        [request setValue:@"application/x-www-fore-urlencoded" forHTTPHeaderField:@"Content-Type"];
        [request setHTTPBody:postData];
        NSLog(@"%@",request);
        NSError *error = [[NSError alloc] init];
        NSHTTPURLResponse * response = nil;
        NSData *urlData = [NSURLConnection  sendSynchronousRequest:request returningResponse:&response error:&error];

1 个答案:

答案 0 :(得分:0)

如果您收到“假装成另一台服务器的服务器”错误,则证书无效。我在浏览器中打开了你的网址,看到证书已过期。