From 8cb3cfc360dbcf01d4feb5c3dbc47e0d26152acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 13 Feb 2023 16:18:56 +0100 Subject: [PATCH] Bump iOS/tvOS minimum version to 11.0, cleanup some code (#81965) In .NET 8 the minimum Apple OS versions we're supporting are iOS/tvOS 11.0 and macOS 10.15. This bumps the version settings in various files and cleans up code that can now assume it's running on a later OS version. For example, it allows us to get rid of a couple `dlsym()` calls in System.Security.Cryptography.Native.Apple. We can also stop building the iOS arm and iOSSimulator x86 runtime packs since 32bit platforms aren't supported by iOS 11 --- Directory.Build.props | 15 ++++- eng/native/build-commons.sh | 2 +- eng/pipelines/common/platform-matrix.yml | 38 ----------- eng/pipelines/coreclr/perf-non-wasm-jobs.yml | 2 - .../templates/build-perf-maui-apps-net7.yml | 7 -- eng/pipelines/runtime-official.yml | 4 -- eng/pipelines/runtime.yml | 2 - eng/targetingpacks.targets | 2 +- .../monocrossaot.sfxproj | 2 +- ...ed-framework-distribution-template-x64.xml | 2 +- .../Interop.X509.cs | 10 +-- src/mono/Directory.Build.props | 14 +--- src/mono/cmake/configure.cmake | 9 ++- src/mono/monoaotcross.proj | 2 +- .../WorkloadManifest.json.in | 32 +-------- .../WorkloadManifest.targets.in | 2 - .../pal_keychain_ios.c | 3 +- .../pal_signverify.c | 5 +- .../pal_ssl.c | 67 ++++++------------- .../pal_x509.c | 44 +++--------- .../pal_x509.h | 3 +- src/native/libs/build-native.sh | 16 ++--- src/tasks/AppleAppBuilder/Xcode.cs | 2 +- src/tests/Common/maui/MauiScenario.targets | 2 - 24 files changed, 69 insertions(+), 218 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index be160eb3086cc..32024db00c900 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -45,7 +45,20 @@ x64 $(TargetArchitecture) - + + + + 11.0 + 11.0 + 2.0 + 5.1 + 10.15 + 11.0 + + + 21 + + diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 7246b091e331c..c56592494332b 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -84,7 +84,7 @@ build_native() exit 1 fi - # keep ANDROID_PLATFORM in sync with src/mono/Directory.Build.props + # keep ANDROID_PLATFORM in sync with SetOSTargetMinVersions in the root Directory.Build.props cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-21 $cmakeArgs" # Don't try to set CC/CXX in init-compiler.sh - it's handled in android.toolchain.cmake already diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index ff5333e089cbf..6e7736b584fff 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -653,25 +653,6 @@ jobs: helixQueueGroup: ${{ parameters.helixQueueGroup }} ${{ insert }}: ${{ parameters.jobParameters }} -# iOS arm - -- ${{ if containsValue(parameters.platforms, 'ios_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: ios - archType: arm - targetRid: ios-arm - platform: ios_arm - shouldContinueOnError: ${{ parameters.shouldContinueOnError }} - jobParameters: - runtimeFlavor: mono - buildConfig: ${{ parameters.buildConfig }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - # iOS arm64 - ${{ if containsValue(parameters.platforms, 'ios_arm64') }}: @@ -710,25 +691,6 @@ jobs: helixQueueGroup: ${{ parameters.helixQueueGroup }} ${{ insert }}: ${{ parameters.jobParameters }} -# iOS Simulator x86 - -- ${{ if containsValue(parameters.platforms, 'iossimulator_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iossimulator - archType: x86 - targetRid: iossimulator-x86 - platform: iossimulator_x86 - shouldContinueOnError: ${{ parameters.shouldContinueOnError }} - jobParameters: - runtimeFlavor: mono - buildConfig: ${{ parameters.buildConfig }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - # iOS Simulator arm64 - ${{ if containsValue(parameters.platforms, 'iossimulator_arm64') }}: diff --git a/eng/pipelines/coreclr/perf-non-wasm-jobs.yml b/eng/pipelines/coreclr/perf-non-wasm-jobs.yml index a95311b9f1a80..e9630aac6a46b 100644 --- a/eng/pipelines/coreclr/perf-non-wasm-jobs.yml +++ b/eng/pipelines/coreclr/perf-non-wasm-jobs.yml @@ -360,7 +360,6 @@ jobs: # - maccatalyst_x64 # - iossimulator_x64 # - ios_arm64 - # - ios_arm # jobParameters: # buildArgs: -s mono+libs+host+packs -c $(_BuildConfig) # nameSuffix: Maui_Packs_Mono @@ -386,7 +385,6 @@ jobs: # - Build_android_x64_release_Maui_Packs_Mono # - Build_maccatalyst_x64_release_Maui_Packs_Mono # - Build_iossimulator_x64_release_Maui_Packs_Mono - # - Build_ios_arm_release_Maui_Packs_Mono # - Build_ios_arm64_release_Maui_Packs_Mono buildArgs: -s mono -c $(_BuildConfig) nameSuffix: MACiOSAndroidMauiNet7 diff --git a/eng/pipelines/coreclr/templates/build-perf-maui-apps-net7.yml b/eng/pipelines/coreclr/templates/build-perf-maui-apps-net7.yml index f9a8cfb046cf7..4f593b18ea8d9 100644 --- a/eng/pipelines/coreclr/templates/build-perf-maui-apps-net7.yml +++ b/eng/pipelines/coreclr/templates/build-perf-maui-apps-net7.yml @@ -82,13 +82,6 @@ steps: # overwriteExistingFiles: true # cleanDestinationFolder: false #- task: ExtractFiles@1 - # displayName: Extract ios-arm runtime - # inputs: - # archiveFilePatterns: $(Build.SourcesDirectory)/MauiTesting/ArtifactPacks/Microsoft.NETCore.App.Runtime.Mono.ios-arm.*.zip - # destinationFolder: $(Build.SourcesDirectory)/MauiTesting/ArtifactPacks/Microsoft.NETCore.App.Runtime.Mono.ios-arm - # overwriteExistingFiles: true - # cleanDestinationFolder: false - #- task: ExtractFiles@1 # displayName: Extract ios-arm64 runtime # inputs: # archiveFilePatterns: $(Build.SourcesDirectory)/MauiTesting/ArtifactPacks/Microsoft.NETCore.App.Runtime.Mono.ios-arm64.*.zip diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index e4b5d79e9ff69..1fd76b56710e7 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -117,9 +117,7 @@ extends: - tvossimulator_arm64 - tvos_arm64 - iossimulator_x64 - - iossimulator_x86 - iossimulator_arm64 - - ios_arm - ios_arm64 - osx_x64 - osx_arm64 @@ -496,10 +494,8 @@ extends: - Build_android_x86_release_AllSubsets_Mono - Build_android_x64_release_AllSubsets_Mono - Build_browser_wasm_Linux_release_AllSubsets_Mono - - Build_ios_arm_release_AllSubsets_Mono - Build_ios_arm64_release_AllSubsets_Mono - Build_iossimulator_x64_release_AllSubsets_Mono - - Build_iossimulator_x86_release_AllSubsets_Mono - Build_iossimulator_arm64_release_AllSubsets_Mono - Build_maccatalyst_arm64_release_AllSubsets_Mono - Build_maccatalyst_x64_release_AllSubsets_Mono diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 55331a222a498..ef7bc0067cd1e 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -364,7 +364,6 @@ extends: runtimeFlavor: mono platforms: - tvossimulator_x64 - - iossimulator_x86 - linux_arm jobParameters: testGroup: innerloop @@ -383,7 +382,6 @@ extends: buildConfig: Release runtimeFlavor: mono platforms: - - ios_arm - linux_musl_x64 jobParameters: testGroup: innerloop diff --git a/eng/targetingpacks.targets b/eng/targetingpacks.targets index 7474ec60b5569..ebdebf46c8b67 100644 --- a/eng/targetingpacks.targets +++ b/eng/targetingpacks.targets @@ -45,7 +45,7 @@ RuntimeFrameworkName="$(LocalFrameworkOverrideName)" LatestRuntimeFrameworkVersion="$(ProductVersion)" RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.Mono.**RID**" - RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86;browser-wasm;wasi-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86" + RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86;browser-wasm;wasi-wasm;ios-arm64;iossimulator-arm64;iossimulator-x64;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86" RuntimePackLabels="Mono" Condition="'@(KnownRuntimePack)' == '' or !@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))"/> $(MonoAotTargets);android-x64;android-arm64;android-x86;android-arm $(MonoAotTargets);browser-wasm $(MonoAotTargets);tvossimulator-x64;tvossimulator-arm64;tvos-arm64 - $(MonoAotTargets);iossimulator-x64;iossimulator-arm64;iossimulator-x86;ios-arm64;ios-arm + $(MonoAotTargets);iossimulator-x64;iossimulator-arm64;ios-arm64 $(MonoAotTargets);maccatalyst-x64;maccatalyst-arm64 diff --git a/src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml b/src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml index 2a1f0b8c7242f..7852e37e9551d 100644 --- a/src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml +++ b/src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml @@ -6,7 +6,7 @@ - + diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs index f741d33a730ca..b2238b3eeabc9 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs @@ -26,7 +26,7 @@ private static partial int AppleCryptoNative_X509GetSubjectSummary( out SafeCFStringHandle cfSubjectSummaryOut); [LibraryImport(Libraries.AppleCryptoNative)] - private static partial int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey, out int pOSStatus); + private static partial int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey); internal static X509ContentType X509GetContentType(ReadOnlySpan data) => X509GetContentType(ref MemoryMarshal.GetReference(data), data.Length); @@ -125,8 +125,7 @@ internal static SafeSecKeyRefHandle X509GetPrivateKeyFromIdentity(SafeSecIdentit internal static SafeSecKeyRefHandle X509GetPublicKey(SafeSecCertificateHandle cert) { SafeSecKeyRefHandle publicKey; - int osStatus; - int ret = AppleCryptoNative_X509GetPublicKey(cert, out publicKey, out osStatus); + int ret = AppleCryptoNative_X509GetPublicKey(cert, out publicKey); if (ret == 1) { @@ -135,11 +134,6 @@ internal static SafeSecKeyRefHandle X509GetPublicKey(SafeSecCertificateHandle ce publicKey.Dispose(); - if (ret == 0) - { - throw CreateExceptionForOSStatus(osStatus); - } - Debug.Fail($"Unexpected return value {ret}"); throw new CryptographicException(); } diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 9f8a0058e0335..aec8a66cfbe6c 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -12,24 +12,12 @@ - - 10.0 - 10.0 - 2.0 - 5.1 - 10.14 - - 11.0 - - + - - - 21 diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index a169aa5f9addc..d85e4883931ea 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -80,7 +80,7 @@ ac_check_funcs ( sched_getaffinity sched_setaffinity chmod lstat getdtablesize ftruncate msync getpeername utime utimes openlog closelog atexit popen strerror_r inet_pton inet_aton poll getfsstat mremap posix_fadvise vsnprintf statfs statvfs setpgid system - fork execv execve waitpid localtime_r mkdtemp getrandom execvp strlcpy stpcpy strtok_r rewinddir + fork execv execve waitpid localtime_r mkdtemp getrandom getentropy execvp strlcpy stpcpy strtok_r rewinddir vasprintf strndup getprotobyname getprotobyname_r getaddrinfo mach_absolute_time gethrtime read_real_time gethostbyname gethostbyname2 getnameinfo getifaddrs access inet_ntop Qp2getifaddrs getpid mktemp) @@ -99,9 +99,9 @@ endif() check_include_files("sys/types.h;sys/user.h" HAVE_SYS_USER_H) -if(NOT HOST_DARWIN) - # getentropy was introduced in macOS 10.12 / iOS 10.0 - ac_check_funcs (getentropy) +if(HOST_IOS OR HOST_MACCAT) + # getentropy isn't allowed in the AppStore: https://github.com/rust-lang/rust/issues/102643 + set(HAVE_GETENTROPY 0) endif() if(NOT DISABLE_THREADS) @@ -248,7 +248,6 @@ if(HOST_WIN32) elseif(HOST_IOS) set(HAVE_SYSTEM 0) set(HAVE_SYS_USER_H 0) - set(HAVE_GETENTROPY 0) if(HOST_TVOS) set(HAVE_PTHREAD_KILL 0) set(HAVE_KILL 0) diff --git a/src/mono/monoaotcross.proj b/src/mono/monoaotcross.proj index b24b75e761f06..f5fe78cbcc2b8 100644 --- a/src/mono/monoaotcross.proj +++ b/src/mono/monoaotcross.proj @@ -12,7 +12,7 @@ $(MonoAotTargets);android-x64;android-arm64;android-x86;android-arm $(MonoAotTargets);browser-wasm $(MonoAotTargets);tvossimulator-x64;tvossimulator-arm64;tvos-arm64 - $(MonoAotTargets);iossimulator-x64;iossimulator-arm64;iossimulator-x86;ios-arm64;ios-arm + $(MonoAotTargets);iossimulator-x64;iossimulator-arm64;ios-arm64 $(MonoAotTargets);maccatalyst-x64;maccatalyst-arm64 diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in index ff0dff2906b16..90a30c8d3d944 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in @@ -52,11 +52,9 @@ "abstract": true, "description": "iOS Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.AOT.Cross.ios-arm", "Microsoft.NETCore.App.Runtime.AOT.Cross.ios-arm64", "Microsoft.NETCore.App.Runtime.AOT.Cross.iossimulator-arm64", - "Microsoft.NETCore.App.Runtime.AOT.Cross.iossimulator-x64", - "Microsoft.NETCore.App.Runtime.AOT.Cross.iossimulator-x86" + "Microsoft.NETCore.App.Runtime.AOT.Cross.iossimulator-x64" ], "extends": [ "runtimes-ios" ], "platforms": [ "win-x64", "win-arm64", "osx-arm64", "osx-x64" ] @@ -65,11 +63,9 @@ "abstract": true, "description": "iOS Mono Runtime Packs", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.ios-arm", "Microsoft.NETCore.App.Runtime.Mono.ios-arm64", "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86" + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64" ], "extends": [ "microsoft-net-runtime-mono-tooling" ], "platforms": [ "win-x64", "win-arm64", "osx-arm64", "osx-x64" ] @@ -247,10 +243,6 @@ "kind": "framework", "version": "${PackageVersion}", }, - "Microsoft.NETCore.App.Runtime.Mono.ios-arm" : { - "kind": "framework", - "version": "${PackageVersion}" - }, "Microsoft.NETCore.App.Runtime.Mono.ios-arm64" : { "kind": "framework", "version": "${PackageVersion}" @@ -263,10 +255,6 @@ "kind": "framework", "version": "${PackageVersion}", }, - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86" : { - "kind": "framework", - "version": "${PackageVersion}", - }, "Microsoft.NETCore.App.Runtime.AOT.Cross.tvos-arm64": { "kind": "Sdk", "version": "${PackageVersion}", @@ -319,14 +307,6 @@ "osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.tvossimulator-x64" } }, - "Microsoft.NETCore.App.Runtime.AOT.Cross.ios-arm": { - "kind": "Sdk", - "version": "${PackageVersion}", - "alias-to": { - "osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm", - "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm", - } - }, "Microsoft.NETCore.App.Runtime.AOT.Cross.ios-arm64": { "kind": "Sdk", "version": "${PackageVersion}", @@ -351,14 +331,6 @@ "osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.iossimulator-x64" } }, - "Microsoft.NETCore.App.Runtime.AOT.Cross.iossimulator-x86": { - "kind": "Sdk", - "version": "${PackageVersion}", - "alias-to": { - "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.iossimulator-x86", - "osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.iossimulator-x86" - } - }, "Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm": { "kind": "Sdk", "version": "${PackageVersion}", diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in index 4de7572881778..fe202f8657a7c 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in @@ -79,11 +79,9 @@ - - diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_keychain_ios.c b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_keychain_ios.c index 634dbd875f9b0..a666297f04d68 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_keychain_ios.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_keychain_ios.c @@ -126,9 +126,8 @@ int32_t AppleCryptoNative_X509StoreRemoveCertificate(CFTypeRef certOrIdentity, u SecCertificateRef cert = (SecCertificateRef)CONST_CAST(void*, certOrIdentity); SecKeyRef publicKey = NULL; CFTypeRef publicKeyLabel = NULL; - int32_t dummyStatus; - if (AppleCryptoNative_X509GetPublicKey(cert, &publicKey, &dummyStatus)) + if (AppleCryptoNative_X509GetPublicKey(cert, &publicKey)) { CFDictionaryRef attrs = SecKeyCopyAttributes(publicKey); publicKeyLabel = CFRetain(CFDictionaryGetValue(attrs, kSecAttrApplicationLabel)); diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_signverify.c b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_signverify.c index 12ad8dc7b5d68..6e7c77e9d7d07 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_signverify.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_signverify.c @@ -123,8 +123,7 @@ static CFStringRef GetSignatureAlgorithmIdentifier(PAL_HashAlgorithm hashAlgorit } } - // Requires macOS 10.13+ or iOS 11+ - /*if (signatureAlgorithm == PAL_SignatureAlgorithm_RSA_Pss) + if (signatureAlgorithm == PAL_SignatureAlgorithm_RSA_Pss) { switch (hashAlgorithm) { @@ -133,7 +132,7 @@ static CFStringRef GetSignatureAlgorithmIdentifier(PAL_HashAlgorithm hashAlgorit case PAL_SHA384: return kSecKeyAlgorithmRSASignatureDigestPSSSHA384; case PAL_SHA512: return kSecKeyAlgorithmRSASignatureDigestPSSSHA512; } - }*/ + } if (signatureAlgorithm == PAL_SignatureAlgorithm_RSA_Raw) { diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c index 4e916693814ae..d37f08ed14e2e 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c @@ -6,14 +6,6 @@ #include "coretls_structs.h" -// 10.13.4 introduced public API but linking would fail on all prior versions. -// For that reason we use function pointers instead of direct call. -// This can be revisited after we drop support for 10.12 and iOS 10 - -static OSStatus (*SSLSetALPNProtocolsPtr)(SSLContextRef context, CFArrayRef protocols) = NULL; -static OSStatus (*SSLCopyALPNProtocolsPtr)(SSLContextRef context, CFArrayRef* protocols) = NULL; -// end of ALPN. - SSLContextRef AppleCryptoNative_SslCreateContext(int32_t isServer) { if (isServer != 0 && isServer != 1) @@ -229,14 +221,12 @@ int32_t AppleCryptoNative_SSLSetALPNProtocols(SSLContextRef sslContext, if (sslContext == NULL || protocols == NULL || pOSStatus == NULL) return -1; - if (!SSLSetALPNProtocolsPtr) - { - // not available. - *pOSStatus = 0; - return 1; - } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // The underlying call handles NULL inputs, so just pass it through - *pOSStatus = (*SSLSetALPNProtocolsPtr)(sslContext, protocols); + *pOSStatus = SSLSetALPNProtocols(sslContext, protocols); +#pragma clang diagnostic pop + return *pOSStatus == noErr; } @@ -245,13 +235,6 @@ int32_t AppleCryptoNative_SSLSetALPNProtocol(SSLContextRef sslContext, void* pro if (sslContext == NULL || protocol == NULL || length <= 0 || pOSStatus == NULL) return -1; - if (!SSLSetALPNProtocolsPtr) - { - // not available. - *pOSStatus = errSecNotAvailable; - return 1; - } - CFStringRef value = CFStringCreateWithBytes(NULL, protocol, length, kCFStringEncodingASCII, 0); if (!value) { @@ -267,8 +250,11 @@ int32_t AppleCryptoNative_SSLSetALPNProtocol(SSLContextRef sslContext, void* pro return -2; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + *pOSStatus = SSLSetALPNProtocols(sslContext, protocolList); +#pragma clang diagnostic pop - *pOSStatus = (*SSLSetALPNProtocolsPtr)(sslContext, protocolList); if (*pOSStatus == 0) { struct SSLContext* ctx = (struct SSLContext*)sslContext; @@ -298,14 +284,12 @@ int32_t AppleCryptoNative_SslGetAlpnSelected(SSLContextRef sslContext, CFDataRef return -1; *protocol = NULL; - if (!SSLCopyALPNProtocolsPtr) - { - // not available. - return 0; - } - CFArrayRef protocols = NULL; - OSStatus osStatus = (*SSLCopyALPNProtocolsPtr)(sslContext, &protocols); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSStatus osStatus = SSLCopyALPNProtocols(sslContext, &protocols); +#pragma clang diagnostic pop if (osStatus == noErr && protocols != NULL && CFArrayGetCount(protocols) > 0) { @@ -705,28 +689,17 @@ int32_t AppleCryptoNative_SslSetEnabledCipherSuites(SSLContextRef sslContext, co } } -// This API is present on macOS 10.5 and newer only -static OSStatus (*SSLSetCertificateAuthoritiesPtr)(SSLContextRef context, CFArrayRef certificates, int32_t replaceExisting) = NULL; - PALEXPORT int32_t AppleCryptoNative_SslSetCertificateAuthorities(SSLContextRef sslContext, CFArrayRef certificates, int32_t replaceExisting) { +#if defined(TARGET_OSX) + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" // The underlying call handles NULL inputs, so just pass it through - - if (!SSLSetCertificateAuthoritiesPtr) - { - // not available. - return 0; - } - - return SSLSetCertificateAuthoritiesPtr(sslContext, certificates, replaceExisting); + return SSLSetCertificateAuthorities(sslContext, certificates, replaceExisting); #pragma clang diagnostic pop -} -__attribute__((constructor)) static void InitializeAppleCryptoSslShim(void) -{ - SSLSetCertificateAuthoritiesPtr = (OSStatus(*)(SSLContextRef, CFArrayRef, int32_t))dlsym(RTLD_DEFAULT, "SSLSetCertificateAuthorities"); - SSLSetALPNProtocolsPtr = (OSStatus(*)(SSLContextRef, CFArrayRef))dlsym(RTLD_DEFAULT, "SSLSetALPNProtocols"); - SSLCopyALPNProtocolsPtr = (OSStatus(*)(SSLContextRef, CFArrayRef*))dlsym(RTLD_DEFAULT, "SSLCopyALPNProtocols"); +#else + return 0; +#endif } diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.c b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.c index d2d8a11554ebe..f8b82864e6778 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.c @@ -42,55 +42,27 @@ AppleCryptoNative_X509DemuxAndRetainHandle(CFTypeRef handle, SecCertificateRef* return 1; } -#if !defined(TARGET_MACCATALYST) -static void InitCertificateCopy(void) -{ -#if defined(TARGET_IOS) || defined(TARGET_TVOS) - // SecCertificateCopyPublicKey on iOS/tvOS has same function prototype as SecCertificateCopyKey - secCertificateCopyKey = (SecKeyRef (*)(SecCertificateRef))dlsym(RTLD_DEFAULT, "SecCertificateCopyKey"); - if (secCertificateCopyKey == NULL) - { - secCertificateCopyKey = (SecKeyRef (*)(SecCertificateRef))dlsym(RTLD_DEFAULT, "SecCertificateCopyPublicKey"); - } -#else - secCertificateCopyKey = (SecKeyRef (*)(SecCertificateRef))dlsym(RTLD_DEFAULT, "SecCertificateCopyKey"); - secCertificateCopyPublicKey = (OSStatus (*)(SecCertificateRef, SecKeyRef*))dlsym(RTLD_DEFAULT, "SecCertificateCopyPublicKey"); -#endif -} -#endif - int32_t -AppleCryptoNative_X509GetPublicKey(SecCertificateRef cert, SecKeyRef* pPublicKeyOut, int32_t* pOSStatusOut) +AppleCryptoNative_X509GetPublicKey(SecCertificateRef cert, SecKeyRef* pPublicKeyOut) { if (pPublicKeyOut != NULL) *pPublicKeyOut = NULL; - if (pOSStatusOut != NULL) - *pOSStatusOut = noErr; - if (cert == NULL || pPublicKeyOut == NULL || pOSStatusOut == NULL) + if (cert == NULL || pPublicKeyOut == NULL) return kErrorUnknownState; -#if !defined(TARGET_MACCATALYST) - pthread_once(&once, InitCertificateCopy); - // SecCertificateCopyPublicKey was deprecated in 10.14, so use SecCertificateCopyKey on the systems that have it (10.14+), - // and SecCertificateCopyPublicKey on the systems that don’t. - if (secCertificateCopyKey != NULL) - { - *pPublicKeyOut = (*secCertificateCopyKey)(cert); - } - else if (secCertificateCopyPublicKey != NULL) + if (__builtin_available(macOS 10.14, iOS 12, tvOS 12, *)) { - *pOSStatusOut = (*secCertificateCopyPublicKey)(cert, pPublicKeyOut); + *pPublicKeyOut = SecCertificateCopyKey(cert); } +#if defined(TARGET_IOS) || defined(TARGET_TVOS) else { - return kErrorBadInput; + *pPublicKeyOut = SecCertificateCopyPublicKey(cert); } - return (*pOSStatusOut == noErr); -#else - *pPublicKeyOut = SecCertificateCopyKey(cert); - return 1; #endif + + return 1; } PAL_X509ContentType AppleCryptoNative_X509GetContentType(uint8_t* pbData, int32_t cbData) diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.h b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.h index a0bc58044c3eb..eca3b550bf7e1 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.h +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.h @@ -30,10 +30,9 @@ Returns 1 on success, 0 on failure, any other value on invalid state. Output: pPublicKeyOut: Receives a CFRetain()ed SecKeyRef for the public key -pOSStatusOut: Receives the result of SecCertificateCopyKey or SecCertificateCopyPublicKey, depending on the OS version. */ PALEXPORT int32_t -AppleCryptoNative_X509GetPublicKey(SecCertificateRef cert, SecKeyRef* pPublicKeyOut, int32_t* pOSStatusOut); +AppleCryptoNative_X509GetPublicKey(SecCertificateRef cert, SecKeyRef* pPublicKeyOut); /* Determines the data type of the provided input. diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 2cc4a850be65c..ad5936423120e 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -93,8 +93,8 @@ elif [[ "$__TargetOS" == linux-bionic && -z "$ROOTFS_DIR" ]]; then __CMakeArgs="-DFORCE_ANDROID_OPENSSL=1 -DANDROID_STL=none $__CMakeArgs" elif [[ "$__TargetOS" == iossimulator ]]; then # set default iOS simulator deployment target - # keep in sync with src/mono/Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props + __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == x86 ]]; then @@ -107,8 +107,8 @@ elif [[ "$__TargetOS" == iossimulator ]]; then fi elif [[ "$__TargetOS" == ios ]]; then # set default iOS device deployment target - # keep in sync with src/mono/Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props + __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm ]]; then @@ -119,8 +119,8 @@ elif [[ "$__TargetOS" == ios ]]; then fi elif [[ "$__TargetOS" == tvossimulator ]]; then # set default tvOS simulator deployment target - # keep in sync with src/mono/Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props + __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm64 ]]; then @@ -131,8 +131,8 @@ elif [[ "$__TargetOS" == tvossimulator ]]; then fi elif [[ "$__TargetOS" == tvos ]]; then # set default tvOS device deployment target - # keep in sync with src/mono/Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" + # keep in sync with the root Directory.Build.props + __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" else diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 66d40e5635d11..ea6e0dd31aaeb 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -181,7 +181,7 @@ public void CreateXcodeProject(string projectName, string cmakeDirectoryPath) targetName = Target.ToString(); break; } - var deployTarget = (Target == TargetNames.MacCatalyst) ? " -DCMAKE_OSX_ARCHITECTURES=" + XcodeArch : " -DCMAKE_OSX_DEPLOYMENT_TARGET=10.1"; + var deployTarget = (Target == TargetNames.MacCatalyst) ? " -DCMAKE_OSX_ARCHITECTURES=" + XcodeArch : " -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0"; var cmakeArgs = new StringBuilder(); cmakeArgs .Append("-S.") diff --git a/src/tests/Common/maui/MauiScenario.targets b/src/tests/Common/maui/MauiScenario.targets index 2faa14ff0426b..c9a589809f6da 100644 --- a/src/tests/Common/maui/MauiScenario.targets +++ b/src/tests/Common/maui/MauiScenario.targets @@ -21,8 +21,6 @@ Condition="'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App' and '%(ResolvedRuntimePack.RuntimeIdentifier)' == 'android-x86'" /> -