1

每次收到每个 https 请求的响应后,我都需要删除 NSURLCredential 存储。在我的情况下没有发生这种情况。下面的方法只在第一次请求时执行,对于下一次请求它不会被调用。当我重新启动应用程序时,它会被调用。我在 SO 中尝试了很多建议,但没有帮助。我怎样才能解决这个问题?

    - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    SecTrustRef trust = challenge.protectionSpace.serverTrust;
    NSURLCredential *cred;
    cred = [NSURLCredential credentialForTrust:trust];
    [challenge.sender useCredential:cred forAuthenticationChallenge:challenge];
}
4

1 回答 1

0

将凭证的persistence属性设置为NSURLCredentialPersistenceNone。这应该确保永远不会存储凭据以供将来使用(假设您还没有为 iOS 2 构建)。

于 2015-09-16T07:17:41.067 回答