次のコードを使用して https 投稿リクエストを作成しようとしています。
NSURL *url = [NSURL URLWithString:@"https://portkey.formspring.me/login/"];
//initialize a request from url
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[url standardizedURL]];
//set http method
[request setHTTPMethod:@"POST"];
//initialize a post data
NSDictionary *postDict = [NSDictionary dictionaryWithObjectsAndKeys:@"username", @"username",
@"password", @"password", nil];
NSError *error=nil;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:postDict
options:NSJSONWritingPrettyPrinted error:&error];
[request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
//set post data of request
[request setHTTPBody:jsonData];
//initialize a connection from request
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
//start the connection
[connection start];
しかし、私は次の応答を得ています。
error Error Domain=NSURLErrorDomain Code=-1202 「このサーバーの証明書は無効です。「portkey.formspring.me」になりすましたサーバーに接続している可能性があり、機密情報が危険にさらされる可能性があります。」UserInfo=0x7564180 {NSLocalizedRecoverySuggestion=サーバーに接続しますか?, NSErrorFailingURLKey= https://portkey.formspring.me/login/、NSLocalizedDescription=このサーバーの証明書は無効です。>「portkey.formspring.me」になりすましているサーバーに接続している可能性があり、機密情報が危険にさらされる可能性があります。, NSUnderlyingError=0x7168a20 "このサーバーの証明書は無効です. 「portkey.formspring.me」になりすましているため、機密情報が危険にさらされる可能性があります。", NSURLErrorFailingURLPeerTrustErrorKey=}
NSURLConnection を使用して投稿リクエストを作成する方法を教えてもらえますか??
前もって感謝します。