NSURLConnection NSMutableURLRequest和HTTPS
我有以下代码将图像上传到网站NSURLConnection NSMutableURLRequest和HTTPS,https,nsurlconnection,Https,Nsurlconnection,我有以下代码将图像上传到网站 [request setURL:nsurl]; [request setHTTPMethod:@"POST"]; NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"]; NSString *contentType = [NSString stringWithFormat:@"multipart/
[request setURL:nsurl];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
/*
now lets create the body of the post
*/
NSMutableData *body = [NSMutableData data];
//parameter1
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"guid\"\r\n\r\n%@", [Settings sharedInstance].uploadID] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//Image
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"filMyFile\"; filename=\"%@\"\r\n", fileName] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: image/png\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:dataObj]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
// setting the body of the post to the reqeust
[request setHTTPBody:body];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
在HTTP上运行时一切正常,但当我切换到HTTPS时,它会失败
错误:错误域=NSURErrorDomain代码=-1005“网络连接丢失。”用户信息=0x1c7f70{NSERRORFAILLINGURLSTRINGKEY=https:
它正在与之通信的服务器是MS server 2008 R2
任何想法都将不胜感激
尼尔。请参阅使用NSURLConnection进行https连接
此外,服务器正在使用ASP.Net 4运行IIS。