ssl urls와 기본 인증을 모두 수행하라는 url 요청을받을 수 없습니다. 나는 다른 관련 질문을 확인했는데 작동하지 않는 것 같아요.NSURLConnection SSL HTTP 기본 인증
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
// NSLog(@"We are checking protection Space!");
if([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
NSLog(@"Can Auth Secure Requestes!");
return YES;
}
else if([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic])
{
NSLog(@"Can Auth Basic Requestes!");
return YES;
//return NO;
}
NSLog(@"Cannot Auth!");
return NO;
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
NSLog(@"Trust Challenge Requested!");
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
else if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic])
{
NSLog(@"HTTP Auth Challenge Requested!");
NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:@"user" password:@"pass" persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
[credential release];
}
무엇이 잘못하고 있는지 알 수없는 것처럼 보입니다. 연결 설명에 보안 연결 실패가 표시됩니다. 나는 단순히 SSL로 시도했지만 아무런 기본 작동하지 않습니다. 나는 또한 SSL과 기본없이 노력하고 잘 작동합니다.
가 혹시 * 연결에 점점 :
이 같은 (ARC) 코드 뭔가를 얻을 것이다 계정에이 복용? 어느 부분에? (SSL을 사용한 기본 인증을 성공적으로 사용했습니다.) – Codo