iOS移动端加载https服务,如何验证自签名证书?

从2017年1月1日起,iOS应用安全级别提升,要求所有上架应用通信需要基于SSL加密。如果应用中SSL加密证书采用了私有证书,那么在代码中该如何处理,才能让基于https私有证书的服务被顺利加载呢?
已邀请:

马克玲

赞同来自: angela

【解决办法】:
如果是基于ArcGIS Runtime SDK for iOS 10.2.*版本开发的地图应用,可以参考以下代码来兼容自签名证书:



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

[[NSURLConnection ags_trustedHosts] addObject:@120win105.esrichina.com];

return YES;
}


对于100.0.0版本, 可以参照以下示例代码:




func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        // Override point for customization after application launch.

        let authenticationManager = AGSAuthenticationManager.sharedAuthenticationManager()         

authenticationManager.trustedHosts.addObject(120win105.esrichina.com)

        return true

    }

要回复问题请先登录注册