Search code examples
iosswiftalamofire

Alamofire 5 request ServerTrustEvaluating issue


I upgraded to Alamofire 5 and now got the issue when making requests:

"Server trust evaluation failed due to reason: A ServerTrustEvaluating value is required for host demo.mXXme.com but none was found."

I setup my manager with DisabledEvaluator in this way:

let manager = Session(configuration: configuration, serverTrustManager: ServerTrustManager(evaluators: [ "demo.mXXme.com": DisabledEvaluator()]))

As I understand DisabledEvaluator should disable any server trust checks. But I still got the issue.

Does any one have ideas how to make my requests work?

Thanks in advance


Solution

  • By default, ServerTrustManager requires that all hosts must have their trusts evaluated. So if you make a request to a domain you don't have in your ServerTrustManager, this error will be produced. These host strings are also case sensitive, so it may not find a match if the domains don't match exactly. I would suggest fixing the matching issue first, but you can disable the required evaluation of all hosts by initializing your ServerTrustManager with an addition parameter:

    ServerTrustManager(allHostsMustBeEvaluated: false, 
                       evaluators: ["demo.mXXme.com": DisabledEvaluator()])
    

    But like I said, you should investigate the matching issue first.