NSURLCredential *credential2 = [NSURLCredential
credentialForTrust:challenge.protectionSpace.serverTrust
credentialWithUser: @"username"
password: @"password"
persistence:NSURLCredentialPersistenceNone];
[challenge.sender useCredential:credential2 forAuthenticationChallenge:challenge];
我需要绕过带有 UIWebView 的自签名证书,同时还能够传入用户名和密码进行身份验证。
NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
和
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"username" 密码:@"password" persistence:NSURLCredentialPersistenceNone];
两者都是单独有效的,当我尝试将它们结合起来时,它们都会大惊小怪......有什么想法吗?