美文网首页
ios 跳过对https 的验证(Error Domain=NS

ios 跳过对https 的验证(Error Domain=NS

作者: 张天奇天张 | 来源:发表于2018-08-06 16:19 被阅读0次

    AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];// allowInvalidCertificates 是否允许无效证书(也就是自建的证书),默认为NO// 如果是需要验证自建证书,需要设置为YESsecurityPolicy.allowInvalidCertificates =YES;    [securityPolicy setValidatesDomainName:NO];    [manger setSecurityPolicy:securityPolicy];

    Swift用Alamofire解决方案

    public func defaultAlamofireManager() -> Manager {letconfiguration = URLSessionConfiguration.default    configuration.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeadersletpolicies: [String: ServerTrustPolicy] = ["api.domian.cn": .disableEvaluation    ]letmanager = Alamofire.SessionManager(configuration: configuration,serverTrustPolicyManager: ServerTrustPolicyManager(policies: policies))        manager.startRequestsImmediately =falsereturnmanager}

    相关文章

      网友评论

          本文标题:ios 跳过对https 的验证(Error Domain=NS

          本文链接:https://www.haomeiwen.com/subject/tbjgvftx.html