Swift中使用Alamofire,Https的免证书设置

    let manager = SessionManager.default
            manager.delegate.sessionDidReceiveChallenge = {
        session,challenge in
        return    (URLSession.AuthChallengeDisposition.useCredential,URLCredential(trust:challenge.protectionSpace.serverTrust!))
    }
    //默认都为允许访问 不鉴权
    let url = "https:x x x"
    
    Alamofire
        .request(url)
        .responseJSON { (response) in
            guard response.result.isSuccess else {

  SVProgressHUD.showError(withStatus: "网络异常!数据加载失败!")

                finished(JSON([]))
                return
            }
            if let value = response.result.value {
                
                let json = JSON(value)
                finished(json)

// SVProgressHUD.dismiss()
}
}
}

你可能感兴趣的:(Swift中使用Alamofire,Https的免证书设置)