相关疑难解决方法(0)

在Enterprise iOS app中使用来自.mobileconfig的客户端SSL证书

我们正尝试在企业iOS应用中使用客户端SSL证书进行用户身份验证.

  • 我们可以在服务器上生成客户端ssl证书
  • 用户可以通过.mobileconfig安装它
  • 在Safari中对Web服务器的身份验证使用已安装的证书.
  • 从iOS应用程序内部发出http请求失败(不使用证书).

我们如何让这个工作?谢谢!

authentication ssl enterprise ssl-certificate ios

12
推荐指数
1
解决办法
3554
查看次数

NSURLConnection,NSURLRequest,不受信任的证书和用户身份验证

大家早上好,

我一直在尝试编写一个从需要身份验证的远程Web服务执行某些GET的应用程序.我的主要问题是这些远程服务器中的大多数(并且有很多远程服务器)没有有效的证书.我有代码接受无效的证书和代码,以正确的uname&pass(下面)来响应挑战.我遇到的问题是让两人一起玩.我似乎无法找到一种方法来发送挑战NSURLCredential或正确链接回调的方法.当我试图将它们连接起来时,我无法NSURLRequest接到didReceiveAuthenticationChallenge两次电话.

任何想法将不胜感激!

认证代码......

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{   
    if(!hasCanceled){
        if ([challenge previousFailureCount] == 0) {
            NSURLCredential *newCredential;
            newCredential=[NSURLCredential credentialWithUser:_username password:_password persistence:NSURLCredentialPersistenceNone];
            [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
        } 
        else {
            [[challenge sender] cancelAuthenticationChallenge:challenge];
            NSLog(@"Bad Username Or Password");
            badUsernameAndPassword = YES;
            finished = YES;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa nsurlconnection nsurlrequest nsurlcredential

8
推荐指数
1
解决办法
3821
查看次数

willSendRequestForAuthenticationChallenge 方法被递归调用

我正在使用 iOS 10。我正在评估自签名证书,如下所示

-(void) connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    NSURLProtectionSpace *protectionSpace = [challenge protectionSpace];

    if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodServerTrust) {

        SecTrustRef trust = [protectionSpace serverTrust];

        SecPolicyRef policyOverride = SecPolicyCreateSSL(true, (CFStringRef)@"HOSTNAME");
        SecTrustSetPolicies(trust, policyOverride);

        CFMutableArrayRef certificates = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);

        /* Copy the certificates from the original trust object */
        CFIndex count = SecTrustGetCertificateCount(trust);
        CFIndex i=0;
        for (i = 0; i < count; i++) {
            SecCertificateRef item = SecTrustGetCertificateAtIndex(trust, i);
            CFArrayAppendValue(certificates, item);
        }

        /* Create a new trust object */
        SecTrustRef newtrust …
Run Code Online (Sandbox Code Playgroud)

ssl ios secure-transport ios10

5
推荐指数
1
解决办法
1976
查看次数