From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:24:04 +0000 (-0400) Subject: Fix compilation on older macOS versions X-Git-Tag: v2.4.6~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F735%2Fhead;p=thirdparty%2Fcups.git Fix compilation on older macOS versions Older versions of macOS do not support SecTrustCopyCertificateChain, so let's revert back to using SecTrustGetCertificateCount. Fixes https://github.com/OpenPrinting/cups/issues/715 --- diff --git a/cups/tls-darwin.c b/cups/tls-darwin.c index fb5caac071..555d636bcd 100644 --- a/cups/tls-darwin.c +++ b/cups/tls-darwin.c @@ -428,7 +428,10 @@ httpCopyCredentials( { OSStatus error; /* Error code */ SecTrustRef peerTrust; /* Peer trust reference */ + CFIndex count; /* Number of credentials */ + SecCertificateRef secCert; /* Certificate reference */ CFDataRef data; /* Certificate data */ + CFIndex i; /* Looping var */ DEBUG_printf(("httpCopyCredentials(http=%p, credentials=%p)", (void *)http, (void *)credentials)); @@ -441,16 +444,15 @@ httpCopyCredentials( if (!(error = SSLCopyPeerTrust(http->tls, &peerTrust)) && peerTrust) { + DEBUG_printf(("2httpCopyCredentials: Peer provided %ld certificates.", (long)SecTrustGetCertificateCount(peerTrust))); + if ((*credentials = cupsArrayNew(NULL, NULL)) != NULL) { - CFArrayRef secArray = SecTrustCopyCertificateChain(peerTrust); - CFIndex i, count = CFArrayGetCount(secArray); + count = SecTrustGetCertificateCount(peerTrust); - DEBUG_printf(("2httpCopyCredentials: Peer provided %ld certificates.", (long)count)); - for (i = 0; i < count; i ++) { - SecCertificateRef secCert = (SecCertificateRef)CFArrayGetValueAtIndex(secArray, i); + secCert = SecTrustGetCertificateAtIndex(peerTrust, i); #ifdef DEBUG CFStringRef cf_name = SecCertificateCopySubjectSummary(secCert); @@ -471,7 +473,6 @@ httpCopyCredentials( CFRelease(data); } } - CFRelease(secArray); } CFRelease(peerTrust);