1

我的网址 https://localhost:44301/api/authenticate swift 5 Alamofire 5+

上面的本地主机正在使用我的招摇和禁用 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,仍然是同样的错误

4

0 回答 0