When calling SecTrustEvaluateWithError() on my SecTrustRef object, the API always returns kSecTrustResultRecoverableTrustFailure. According to header file, this means:
Indicates a trust policy failure which can be overridden by the user. This value may be returned by the
SecTrustEvaluatefunction but not stored as part of the user trust settings.
Being overridable, I changed the trust settings for the untrusted certificate using Keychain Access app like so:
Yet this seems to make no difference, the result is still kSecTrustResultRecoverableTrustFailure, so what am I doing wrong?

It turned out that the problem was caused by calling
SecTrustSetAnchorCertificates(), which I used to add own CA certificates before callingSecTrustEvaluateWithError().The meanwhile deprecated function
SecTrustEvaluate()contains an important note in the documentation:Source: https://developer.apple.com/documentation/security/1394363-sectrustevaluate
While this note is missing in the
SecTrustEvaluateWithError()documentation, it also applies to this function as well as toSecTrustEvaluateAsyncWithError(). If I make sure thatSecTrustSetAnchorCertificates()is never called, then the user override works as expected (with that override, the cert is considered trusted by the system, without it isn't, which is expected behavior).