我正在使用iOS sdk5.0。我正在使用NSURLConnection创建链接并创建请求。但我的控制不会进入didReceiveAuthenticationChallenge方法。在iOS5.0中没有调用didReceiveAuthenticationChallenge吗?didReceiveAuthenticationChallenge未被调用
5
A
回答
14
根据DocsNSURLConnectionDelegate
的
connection:canAuthenticateAgainstProtectionSpace:
connection:didReciveAuthenticationChallenge:
connection:didCancelAuthenticationChallenge:
已被取消,新的代码应该采取
connection:willSendRequestForAuthenticationChallenge
老代表将仍然被调用的兼容性,但在处理与认证挑战带来了更多的延迟。
1
我有同样的问题(请参阅我上面的评论)。在我的搜索中,我遇到了这个要点:https://gist.github.com/1675763。我尝试了AUTH_NEW路径中的代码。代表仍然没有被召唤。然后我注意到第40行的注释: “也许iOS 5不支持DSA签名算法。”
我做了一些搜索,并没有发现任何内容表明这是一个限制是一个问题。最后,在绝望中,我改变了这一点。我使用java的keytool(Java的openssl +的重新创建版本)来生成我的自签名证书。它默认使用DSA。绝望之余,我用旗帜迫使它使用RSA。然后代表被调用,上面的要点代码工作。
我还没有看到任何文件说你不能使用DSA。 openssl似乎默认使用RSA,所以使用它的人可能永远不会遇到这种情况。
小故事:检查你的证书并确保它是用RSA而不是DSA签名的。
0
我想强调克里斯·威斯汀的观点。除此之外,我实际上创建了一个RSA密钥,但意外地将DSA密钥复制到服务器。因此,如果有疑问,您需要使用-v(verbose)命令来确保您已获得适当的证书。例如:
keytool -list -v -keystore <name of keystore here>
相关问题
- 1. didReceiveAuthenticationChallenge只会被调用一次iPhone
- 2. didReceiveAuthenticationChallenge没有被调用使用ftp协议
- 3. NSURLConnection sendAsynchronousRequest:queue:completionHandler:不调用委托方法 - didReceiveAuthenticationChallenge
- 4. didReceiveAuthenticationChallenge委托没有在Swift中调用
- 5. WebMethod未被调用
- 6. loadUserByUsername未被调用
- 7. RenderDelegate未被调用
- 8. MPMoviePlayerPlaybackDidFinishNotification未被调用
- 9. initWithNibName未被调用
- 10. onDraw()未被调用
- 11. Page_PreInit未被调用?
- 12. dispatch_async未被调用
- 13. UIGestureRecognizer未被调用
- 14. forwardInvocation未被调用?
- 15. popoverControllerDidDismissPopover未被调用
- 16. viewDidLoad未被调用
- 17. OnKeyListener.onKey未被调用
- 18. SnmpExtensionInit未被调用
- 19. Dllmain未被调用?
- 20. didFinishLaunchingWithOptions未被调用
- 21. onActivityResult未被调用?
- 22. Iphone didReceiveAuthenticationChallenge方法
- 23. ios didReceiveAuthenticationChallenge状态
- 24. didReceiveAuthenticationChallenge导致EXC_BAD_ACCESS
- 25. mousePove被调用时未调用mouseMove
- 26. Unity OnLevelWasLoaded未被调用
- 27. setChangeListener方法未被调用
- 28. Scriptaulous JS未被调用
- 29. Cef未被调用OnContextCreated()
- 30. Spring Boot @RepositoryEventHandler未被调用
谢谢himanshu。所以,而不是这个方法,如果NSURLConnectionDelegate,我应该使用连接:willSendRequestForAuthenticationChallenge(在iOS 5中)。但是,当我在5.0以外的版本中运行此代码时,它会给出错误。对?? – anshul
再次根据[文档](http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSURLConnectionDelegate)'如果连接:willSendRequestForAuthenticationChallenge:未实现,较旧的,已弃用的方法连接:canAuthenticateAgainstProtectionSpace :,连接:didReceiveAuthenticationChallenge :,连接:didCancelAuthenticationChallenge:被调用替代.' –
我有一个新的实现,willSendRequestForAuthenticationChallenge设置为代表,并没有被调用。我试图绕过使用自签名的证书进行测试,并且我得到的API请求失败,出现错误:Error Domain = NSURLErrorDomain Code = -1200“发生SSL错误,无法建立与服务器的安全连接。 “等等。搜索表明这个委托方法应该允许我这样做,但委托甚至没有被调用。 –