代码之家  ›  专栏  ›  技术社区  ›  Steven

NSURLAuthenticationMethodClientCertificate存在问题,无法返回

  •  0
  • Steven  · 技术社区  · 7 年前

    -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
    {
      if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodServerTrust) {
    
    // do something
    
    } else if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodClientCertificate)  {
    
    // Do something
    
    }
    }
    

    在iOS 10中,响应返回

     NSURLProtectionSpace* protectionSpace = challenge.protectionSpace;
    
    NSURLAuthenticationMethodClientCertificate
    

    问题在于iOS 11中的响应返回:

    NSURLAuthenticationMethodServerTrust
    

    NSURLAuthenticationMethodClientCertificate 第一本书,而不是 NSURLAuthenticationMethodServerTrust

    感谢您的帮助:)

    1 回复  |  直到 7 年前
        1
  •  0
  •   Steven    7 年前

    经过几个小时的研究,我将在这里回答这个问题。 NSURLAuthenticationMethodServerTrust 总是先到后过 但在iOS 10中,它的工作原理相反。