Ok, I have good news and bad news. I have a friend who is a Mac / iOS security expert, and he works a lot in this area. In fact, he had something very similar. The information I received from him is as follows. But the bad news is not an easy command line method - you will most likely have to unscrew the Mac application to do this using the methods below.
- Technics ---
The certificate inside this XML file ... is read into the NSData object; although there are usually 3 certificates; at least in profiles created by Apple. I donβt know if this is so.
If there are 3 certificates, it is usually enough to verify that one of them (usually the last one) is called "Apple Root CA" and has a SHA1 value in hexadecimal format "611E5B662C593A08FF58D14AE22452D198DF6C60" - I use the SHA1 function in openssl.h for this.
If there is only one certificate, it is likely a certificate sheet. To check if this is normal, it is more difficult, because a full "chain of trust" is usually required to check.
In any case, you need to associate with Security.framework, call SecCertificateCreateWithData () with NSData (in an appropriate way) to get SecCertificateRef.
A relative label could be a call to SecCertificateCopyValues ββ() to get the "Authorization key identifier (2.5.29.35)" field (the dictionary key for this seems to be kSecOIDAuthorityKeyIdentifier) ββand check if this field value is hexadecimal "E7342A2E22DE39606BB494CE7783512F31, 31731123 313 313 313 313 313 313 313 313 313 313 313 313 313 313 313 313 313 311 316 311 316 311 316 311 361 316 311 361 316 311 361 316 311 361 316 311 361 316 311 316 311 316 311 361 391 361 391 361 391 603 seems to be valid for all certificates issued by Apple. Returning from SecCertificateCopyValues ββ() is a nested dictionary dictionary, so you need to expand it to find this.
The full and complete answer would be to pass the certificate to SecTrustSettingsCopyTrustSettings (), sequentially, kSecTrustSettingsDomainUser, kSecTrustSettingsDomainAdmin, kSecTrustSettingsDomainSystem, checking if the certificate is explicitly trusted or not. If the intermediate certificate is not installed on the machine, which is likely to fail if it has a sheet certificate.
source share