The customer (large retail enterprise), has an in-house CA - i.e., the self-signed root CA is not included in iOS by default. They use AirWatch to push the app to thousands of devices, but AirWatch cannot push the root certificate for the in-house CA.
Huh? it’s absolutely standard for enterprises to have their own root CA and for MDM solutions to push that root CA to devices. I strongly recommend you push because on this because, while you can work around it on the client, that workaround has a number of drawbacks:
It requires you to write code, which is always best to avoid if you can.
Any mistake in that code is likely to result in a serious security vulnerability.
That code requires you to disable App Transport Security for the domains in question, which is poor form in general.
If, just for the sake of testing, you install the root certificate on the device, do things work?
With regards the code you posted, let me start by saying that the very existence of your
disableCertificateValidation
option is a mistake IMO. That’s a classic gateway for security bugs. You shouldn’t ever need to this because:
As to why things are failing, it’s hard to say based on the info presented. The “Root certificate is not trusted” implies that you can’t find a path from the leaf certificate of the server to a trust root. Given that you’ve supplied the expected trusted root, that means that either the server isn’t using the leaf issued by that root or the server isn’t pass you all the intermediates required to go from its leaf to that root. What is the certificate chain supposed to look like? What do you get back when you dump the certificate chain from the trust object? You can do that using
SecTrustGetCertificateCount
and
SecTrustGetCertificateAtIndex
.
With regards “Policy requirements not met”, that’s definitely a weird one. The last time I saw this was during the earlier iOS 9 release cycle, where iOS was strictly enforcing the Name Constraints extension. What I recommend you do here is first resolve the certificate chain problem and then come back to this one.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"