Skip to content

Commit

Permalink
CBL-5627: Update min MacOS version to 12.0 (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbirks authored May 16, 2024
1 parent bb7d167 commit 7a11b71
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 52 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SQLite3_UnicodeSN - The snowball tokenizer library for SQLite
This project is built for the following platforms at Couchbase:
- Windows 10
- UWP
- macOS 10.14
- macOS 12.0
- CentOS 7 (gcc 7.x+)
- Android API 22+
Expand All @@ -42,7 +42,7 @@ cmake_policy(VERSION 3.9)
cmake_policy(SET CMP0057 NEW)

# Mac/apple setup -- must appear before the first "project()" line"
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
if(NOT DEFINED CMAKE_OSX_SYSROOT)
# Tells Mac builds to use the current SDK's headers & libs, not what's in the OS.
set(CMAKE_OSX_SYSROOT macosx)
Expand Down
53 changes: 25 additions & 28 deletions Crypto/PublicKey+Apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,
if (@available(macOS 11.0, iOS 14.0, *)) {
publicKeyRef = SecTrustCopyKey(trustRef);
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
publicKeyRef = SecTrustCopyPublicKey(trustRef);
#pragma clang diagnostic pop
}
CFRelease(policyRef);
CFRelease(trustRef);
Expand Down Expand Up @@ -536,21 +539,12 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,

SecTrustResultType result; // Result will be ignored.
OSStatus err;
if (@available(iOS 12.0, *)) {
CFErrorRef cferr;
if (!SecTrustEvaluateWithError(trustRef, &cferr)) {
auto error = (__bridge NSError*)cferr;
LogVerbose(TLSLogDomain, "SecTrustEvaluateWithError failed: %s", error.description.UTF8String);
}
err = SecTrustGetTrustResult(trustRef, &result);
} else {
#if TARGET_OS_MACCATALYST
LogError(TLSLogDomain, "Catalyst:SecTrustEvaluateWithError not available, macOS < 10.14, iOS < 12");
error::_throw(error::UnsupportedOperation, "Catalyst:SecTrustEvaluateWithError not available, macOS < 10.14, iOS < 12");
#else
err = SecTrustEvaluate(trustRef, &result);
#endif
CFErrorRef cferr;
if (!SecTrustEvaluateWithError(trustRef, &cferr)) {
auto error = (__bridge NSError*)cferr;
LogVerbose(TLSLogDomain, "SecTrustEvaluateWithError failed: %s", error.description.UTF8String);
}
err = SecTrustGetTrustResult(trustRef, &result);
checkOSStatus(err, "SecTrustEvaluate",
"Couldn't evaluate the trust to get certificate chain" );

Expand All @@ -569,7 +563,10 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,
#endif
{
for (CFIndex i = 1; i < count; i++) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SecCertificateRef ref = SecTrustGetCertificateAtIndex(trustRef, i);
#pragma clang diagnostic pop
NSData* data = (NSData*) CFBridgingRelease(SecCertificateCopyData(ref));
cert->append(new Cert(slice(data)));
}
Expand Down Expand Up @@ -639,7 +636,10 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,
LogError(TLSLogDomain, "Catalyst:SecTrustEvaluateWithError not available, macOS < 10.14 and iOS < 12");
error::_throw(error::UnsupportedOperation, "Catalyst:SecTrustEvaluateWithError not available, macOS < 10.14 and iOS < 12");
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
err = SecTrustEvaluate(trustRef, &result);
#pragma clang diagnostic pop
#endif
}

Expand Down Expand Up @@ -694,7 +694,10 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,
#endif
{
for (CFIndex i = count - 1; i >= 0; i--) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SecCertificateRef ref = SecTrustGetCertificateAtIndex(trustRef, i);
#pragma clang diagnostic pop
if (getChildCertCount(ref) < 2) {
NSDictionary* params = @{
(id)kSecClass: (id)kSecClassCertificate,
Expand Down Expand Up @@ -755,21 +758,12 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,
SecTrustResultType result;
OSStatus err;

if (@available(iOS 12.0, *)) {
CFErrorRef cferr;
if (!SecTrustEvaluateWithError(trust, &cferr)) {
auto error = (__bridge NSError*)cferr;
LogVerbose(TLSLogDomain, "SecTrustEvaluateWithError failed: %s", error.description.UTF8String);
}
err = SecTrustGetTrustResult(trust, &result);
} else {
#if TARGET_OS_MACCATALYST
LogError(TLSLogDomain, "Catalyst:SecTrustEvaluateWithError not available, macOS < 10.14, iOS < 12.0");
error::_throw(error::UnsupportedOperation, "Catalyst:SecTrustEvaluateWithError not available, macOS < 10.14, iOS < 12.0");
#else
err = SecTrustEvaluate(trust, &result);
#endif
CFErrorRef cferr;
if (!SecTrustEvaluateWithError(trust, &cferr)) {
auto error = (__bridge NSError*)cferr;
LogVerbose(TLSLogDomain, "SecTrustEvaluateWithError failed: %s", error.description.UTF8String);
}
err = SecTrustGetTrustResult(trust, &result);
checkOSStatus(err, "SecTrustEvaluate", "Couldn't validate certificate");
LogTo(TLSLogDomain, " ...SecTrustEvaluate returned %d", result);
if (result != kSecTrustResultUnspecified && result != kSecTrustResultProceed)
Expand All @@ -796,7 +790,10 @@ virtual int _sign(int/*mbedtls_md_type_t*/ mbedDigestAlgorithm,
#endif
{
for (CFIndex i = 1; i < certCount; ++i) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
auto certRef = SecTrustGetCertificateAtIndex(trust, i);
#pragma clang diagnostic pop
LogTo(TLSLogDomain, " ... root %s", describe(certRef).c_str());
CFDataRef dataRef = SecCertificateCopyData(certRef);
CFAutorelease(dataRef);
Expand Down
23 changes: 3 additions & 20 deletions LiteCore/Support/Instrumentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ namespace litecore {

#if defined(__APPLE__) && LITECORE_SIGNPOSTS

# if TARGET_OS_MACCATALYST
os_log_t LiteCore = os_log_create("com.couchbase.litecore", "signposts");
;
# endif

enum Color {
blue,
Expand All @@ -35,30 +33,15 @@ namespace litecore {
};

void Signpost::mark(Type t, uintptr_t param, uintptr_t param2) {
# if TARGET_OS_MACCATALYST
if ( __builtin_available(iOS 12.0, *) )
os_signpost_event_emit(LiteCore, t, "LiteCore", "%lu %lu %d %d", param, param2, 0, (t % 5));
# else
kdebug_signpost(t, param, param2, 0, (t % 5));
# endif
os_signpost_event_emit(LiteCore, t, "LiteCore", "%lu %lu %d %d", param, param2, 0, (t % 5));
}

void Signpost::begin(Type t, uintptr_t param, uintptr_t param2) {
# if TARGET_OS_MACCATALYST
if ( __builtin_available(iOS 12.0, *) )
os_signpost_interval_begin(LiteCore, t, "LiteCore", "%lu %lu %d %d", param, param2, 0, (t % 5));
# else
kdebug_signpost_start(t, param, param2, 0, (t % 5));
# endif
os_signpost_interval_begin(LiteCore, t, "LiteCore", "%lu %lu %d %d", param, param2, 0, (t % 5));
}

void Signpost::end(Type t, uintptr_t param, uintptr_t param2) {
# if TARGET_OS_MACCATALYST
if ( __builtin_available(iOS 12.0, *) )
os_signpost_interval_end(LiteCore, t, "LiteCore", "%lu %lu %d %d", param, param2, 0, (t % 5));
# else
kdebug_signpost_end(t, param, param2, 0, (t % 5));
# endif
os_signpost_interval_end(LiteCore, t, "LiteCore", "%lu %lu %d %d", param, param2, 0, (t % 5));
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions Xcode/xcconfigs/Project.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LITECORE_VERSION_STRING = 3.2.0
LITECORE_BUILD_NUMBER = 0

IPHONEOS_DEPLOYMENT_TARGET = 12.0
MACOSX_DEPLOYMENT_TARGET = 10.14
TVOS_DEPLOYMENT_TARGET = 10.0
MACOSX_DEPLOYMENT_TARGET = 12.0
TVOS_DEPLOYMENT_TARGET = 12.0
ONLY_ACTIVE_ARCH = YES
SKIP_INSTALL = YES
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator
Expand Down

0 comments on commit 7a11b71

Please sign in to comment.