如果您使用NSURLConnection連接到服務器,則應該實現在接下來的委託方法:
- (BOOL)connection:(NSURLConnection *)conn canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace;
// A delegate method called by the NSURLConnection when something happens with the
// connection security-wise. We defer all of the logic for how to handle this to
// the ChallengeHandler module (and it's very custom subclasses).
- (void)connection:(NSURLConnection *)conn didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
// A delegate method called by the NSURLConnection when you accept a specific
// authentication challenge by returning YES from -connection:canAuthenticateAgainstProtectionSpace:.
// Again, most of the logic has been shuffled off to the ChallengeHandler module; the only
// policy decision we make here is that, if the challenge handle doesn't get it right in 5 tries,
// we bail out.
我建議你通過蘋果通過這個樣本看:Advanced Url Connections
你想給我們證書對服務器進行身份驗證? – Nekto
是的,這是正確的。我似乎無法完成身份驗證。 –