我的网址https://localhost:44301/api/authenticate swift 5 Alamofire 5+
以上本地主机是我的 Swagger 和 Postman 与SSL禁用工作,我得到适当的回应
private let session: Session = {
let manager = ServerTrustManager(evaluators: ["localhost:44301": DisabledTrustEvaluator()])
let configuration = URLSessionConfiguration.af.default
return Session(configuration: configuration, serverTrustManager: manager)
}()
//POST method call using Alamofire
let strURL = https://localhost:44301/api/authenticate
session.request(strURL, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON {
...
//handle response
}
字符串
我得到的错误
Url : https://localhost:44301/api/Authenticate, Parameters : {"userNameOrEmailAddress":"admin","password":"123qwe"}
failure(Alamofire.AFError.serverTrustEvaluationFailed(reason: Alamofire.AFError.ServerTrustFailureReason.noRequiredEvaluator(host: "localhost")))
serverTrustEvaluationFailed(reason: Alamofire.AFError.ServerTrustFailureReason.noRequiredEvaluator(host: "localhost"))
型
我已经在ServerTrustManager中尝试了localhost而不是localhost:44301,仍然错误
1条答案
按热度按时间z0qdvdin1#
您需要创建自定义会话
字符串
之后
型