作家
登录

iOS AFNetworking框架HTTPS请求配置

作者: 来源: 2017-04-23 16:50:37 阅读 我要评论

  •                 SecIdentityCopyCertificate(identity, &certificate); 
  •                 const void*certs[] = {certificate}; 
  •                 CFArrayRef certArray =CFArrayCreate(kCFAllocatorDefault, certs,1,NULL); 
  •                 credential =[NSURLCredential credentialWithIdentity:identity certificates:(__bridge  NSArray*)certArray persistence:NSURLCredentialPersistencePermanent]; 
  •                 disposition =NSURLSessionAuthChallengeUseCredential; 
  •             } 
  •         } 
  •     } 
  •     *_credential = credential; 
  •     return disposition; 
  • }]; 
  •  
  • return manager; 
  •  
  • /** 
  • **加载PKCS12证书,pfx或p12 
  • **  
  • **/ 
  • +(BOOL)extractIdentity:(SecIdentityRef*)outIdentity andTrust:(SecTrustRef *)outTrust fromPKCS12Data:(NSData *)inPKCS12Data { 
  •     OSStatus securityError = errSecSuccess; 
  •     //client certificate password 
  •     NSDictionary*optionsDictionary = [NSDictionary dictionaryWithObject:@"你的p12暗码" 
  •                                                                 forKey:(__bridge id)kSecImportExportPassphrase]; 
  •  
  •     CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL); 
  •     securityError = SecPKCS12Import((__bridge CFDataRef)inPKCS12Data,(__bridge CFDictionaryRef)optionsDictionary,&items); 
  •  
  •     if(securityError == 0) { 
  •         CFDictionaryRef myIdentityAndTrust =CFArrayGetValueAtIndex(items,0); 
  •         const void*tempIdentity =NULL
  •         tempIdentity= CFDictionaryGetValue (myIdentityAndTrust,kSecImportItemIdentity); 
  •         *outIdentity = (SecIdentityRef)tempIdentity; 
  •         const void*tempTrust =NULL
  •         tempTrust = CFDictionaryGetValue(myIdentityAndTrust,kSecImportItemTrust); 
  •         *outTrust = (SecTrustRef)tempTrust; 
  •     } else { 
  •         NSLog(@

      推荐阅读

      人工智能时代,技术人员应该掌握的5项技能

    3.平台及数据治理才能 在2016年,人工智能公司产生的资金收入估值达到了80亿美元,并且这一数字有望在将来的三年内翻五倍。企业家们都纷纷投资人工智能,不仅将其作为一种降低成本的方法,>>>详细阅读


    本文标题:iOS AFNetworking框架HTTPS请求配置

    地址:http://www.17bianji.com/lsqh/34908.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)