HTTPS +表单登录NSURLConnection

时间:2013-06-30 12:50:38

标签: ios authentication login nsurlconnection

我正在使用HTTPS进行表单登录页面。 拦截时通过

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge` 

并提取通过

使用的身份验证方法
NSString *authenticationMethod = [[challenge protectionSpace] authenticationMethod];

我得到以下

NSURLAuthenticationMethodServerTrust

但预期结果应为

NSURLAuthenticationMethodHTMLForm

这是由于使用HTTPS吗?

1 个答案:

答案 0 :(得分:0)

简答:是的

NSURLAuthenticationMethodServerTrust身份验证方法的目的是客户端可以验证并信任服务器实际上是它假装的服务器。

NSURLAuthenticationMethodHTMLForm用于通过网络表单对用户进行身份验证。服务器发送Web表单并请求用户凭据。此身份验证不需要通过SSL / TLS发送。但是,用户的凭据将以明文形式发送,从安全角度来看这是一件坏事。

客户端身份验证也是TLS协议的一部分。在这种情况下,您可能会收到一种方法为NSURLAuthenticationMethodClientCertificate的质询。

请注意,您可能会遇到多个身份验证问题。