We are trying to evaluate certificate trust chain in our macOS app. We are setting the certificate chain (Root and two Intermediate CA certificates) using SecTrustSetAnchorCertificates
and then calling SecTrustEvaluateWithError
. The result is success.
Next time, we are calling SecTrustSetAnchorCertificates
with one intermediate CA certificate missing in the certificate chain and then calling SecTrustEvaluateWithError
for our server trust. The result is still success.
Next, we are calling SecTrustSetAnchorCertificates
with all intermediate certificates but missing Root CA in certificate chain and then calling SecTrustEvaluateWithError
for our server trust. The result is false/unsuccessful.
The first and third scenarios are expected. But how is trust evaluation successful when one of intermediate CA certificate is missing? Is macOS caching the intermediate CA certificates we have provided to SecTrustSetAnchorCertificates
some other time and using it the next time when it is missing one of intermediate CA certificates since the documentation says intermediate CA certificates are looked up in different location including
Among any certificates you previously provided by calling SecTrustSetAnchorCertificates(_:_:)
but not the Root CA?
If caching is the reason, is there a way we can clear cached intermediate CA certificates so that it only uses the certificate chain I provide in most recent call to SecTrustSetAnchorCertificates
? I have already tried passing nil to SecTrustSetAnchorCertificates
and then passing the certificate chain in subsequent call. The result is still a success.
Note: All our Root and intermediate CA certificates are custom certificates and not available outside. We have also tried to set false in SecTrustGetNetworkFetchAllowed
and result is still the same.