X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/6b200bc335dc93c5516ccb52f14bd896d8c7fad7..07691282a056c4efea71e1e505527601e8cc166b:/OSX/libsecurity_keychain/lib/SecTrustOSXEntryPoints.cpp?ds=inline diff --git a/OSX/libsecurity_keychain/lib/SecTrustOSXEntryPoints.cpp b/OSX/libsecurity_keychain/lib/SecTrustOSXEntryPoints.cpp index 205ccbb2..49b9e324 100644 --- a/OSX/libsecurity_keychain/lib/SecTrustOSXEntryPoints.cpp +++ b/OSX/libsecurity_keychain/lib/SecTrustOSXEntryPoints.cpp @@ -28,6 +28,12 @@ #include "SecTrustOSXEntryPoints.h" +#include +#include +#include +#include +#include + #include #include #include @@ -42,26 +48,9 @@ #include #include -#include -#include -#include -#include -#include -#include - -/* - * MARK: CFRunloop - */ -static void *SecTrustOSXCFRunloop(__unused void *unused) { - CFRunLoopTimerRef timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, (CFTimeInterval) UINT_MAX, 0, 0, 0, ^(__unused CFRunLoopTimerRef _timer) { - /* do nothing */ - }); - - /* add a timer to force the runloop to stay running */ - CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode); +void SecTrustLegacySourcesListenForKeychainEvents(void) { /* Register for CertificateTrustNotification */ - int out_token = 0; notify_register_dispatch(kSecServerCertificateTrustNotification, &out_token, dispatch_get_main_queue(), @@ -72,37 +61,6 @@ static void *SecTrustOSXCFRunloop(__unused void *unused) { SecTrustSettingsPurgeUserAdminCertsCache(); }); - - try { - CFRunLoopRun(); - } - catch (...) { - /* An exception was rethrown from the runloop. Since we can't reliably - * obtain info about changes to keychains or trust settings anymore, - * just exit and respawn the process when needed. */ - - secerror("Exception occurred in CFRunLoopRun; exiting"); - exit(0); - } - CFRelease(timer); - return NULL; -} - -void SecTrustLegacySourcesEventRunloopCreate(void) { - /* A runloop is currently necessary to receive notifications about changes in the - * legacy keychains and trust settings. */ - static dispatch_once_t once; - - dispatch_once(&once, ^{ - pthread_attr_t attrs; - pthread_t thread; - - pthread_attr_init(&attrs); - pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED); - - /* we do this with traditional pthread to avoid impacting our 512 WQ thread limit since this is a parked thread */ - pthread_create(&thread, &attrs, SecTrustOSXCFRunloop, NULL); - }); } /* @@ -166,7 +124,7 @@ OSStatus SecTrustLegacyCRLStatus(SecCertificateRef cert, CFArrayRef chain, CFURL /* serialNumber is a CSSM_DATA with the value from the TBS Certificate. */ CSSM_DATA serialNumber = { 0, NULL }; - serialData = SecCertificateCopySerialNumber(cert, NULL); + serialData = SecCertificateCopySerialNumberData(cert, NULL); if (serialData) { serialNumber.Data = (uint8_t *)CFDataGetBytePtr(serialData); serialNumber.Length = CFDataGetLength(serialData); @@ -272,6 +230,7 @@ static void async_ocspd_complete(async_ocspd_t *ocspd) { bool SecTrustLegacyCRLFetch(async_ocspd_t *ocspd, CFURLRef currCRLDP, CFAbsoluteTime verifyTime, SecCertificateRef cert, CFArrayRef chain) { + ocspd->start_time = mach_absolute_time(); dispatch_async(ocspd->queue, ^ { OSStatus status = fetchCRL(currCRLDP, verifyTime); switch (status) {