皆さん、良い一日
です。インターネットを介したコンテンツのダウンロードを管理するシングルトンに取り組んでいます。ASIHttpリクエストが存在し、それが優れたlibであることは知っていますが、それを使用しない理由は私自身にあります。
このクラスは、1つのことを除いて、かなりうまく機能します。MobileMeアカウントのパブリックフォルダを処理しようとしていますが、うまくいきません。その中にファイルをアップロードし、クラスを使用してダウンロードしようとしました。stackOFに関するいくつかの質問を読んだり、ドキュメントを読んだりして、そのコードを思いついたのですが、うまくいかないようです。
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
if([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
NSLog(@"SERVER TRUST AUTH");
return YES;
}
else if([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic])
{
NSLog(@"HTTP BASIC AUTH");
return YES;
}
NSLog(@"NO AUTH");
return NO;
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"Authetication");
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
NSLog(@"Trust Challange");
SecTrustResultType trustResultType;
OSStatus err=SecTrustEvaluate(challenge.protectionSpace.serverTrust, &trustResultType);
NSLog(@"SecTrustResult %lu %ld",trustResultType,err);
if (trustResultType == kSecTrustResultProceed || trustResultType == kSecTrustResultConfirm || trustResultType == kSecTrustResultUnspecified) {
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
else{
[challenge.sender cancelAuthenticationChallenge:challenge];
}
// [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
else if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic])
{
NSLog(@"HTTP Challenge");
NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:@"user" password:@"pass" persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
[credential release];
}
else{
[[challenge sender]cancelAuthenticationChallenge:challenge];
}
}
ログから、evaluate関数がkSecTrustResultUnspecificedに対応する4の結果を返すことがわかりますが、チャレンジ送信者にに言っても何も機能しないため、スタックしていcontinueWithoutCredentialForAuthenticationChallenge
ます。ファイルのURLは次のとおりです。https ://public.me.com/XXXX/Objective.zip (リンクは削除されています)zipは、クラスにも実装したObjectiveZipライブラリです。
なにか提案を?