Skip to content

[Security] Implement up to Xcode 16.4 beta 1. #22754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/ObjCRuntime/SystemVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ internal static bool IsAtLeastXcode16 {
}
}
static bool? is_at_least_xcode_16;

[SupportedOSPlatformGuard ("ios18.5")]
[SupportedOSPlatformGuard ("maccatalyst18.5")]
[SupportedOSPlatformGuard ("macos15.5")]
[SupportedOSPlatformGuard ("tvos18.5")]
internal static bool IsAtLeastXcode16_4 {
get {
if (is_at_least_xcode_16_4 is null) {
#if __MACOS__
is_at_least_xcode_16_4 = OperatingSystem.IsMacOSVersionAtLeast (15, 5);
#elif __MACCATALYST__
is_at_least_xcode_16_4 = OperatingSystem.IsMacCatalystVersionAtLeast (18, 5);
#elif __IOS__
is_at_least_xcode_16_4 = OperatingSystem.IsIOSVersionAtLeast (18, 5);
#elif __TVOS__
is_at_least_xcode_16_4 = OperatingSystem.IsTvOSVersionAtLeast (18, 5);
#else
#error Unknown platform
#endif
}
return is_at_least_xcode_16_4.Value;
}
}
static bool? is_at_least_xcode_16_4;
}
}
#endif
55 changes: 50 additions & 5 deletions src/Security/SecProtocolMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,35 @@ public class SecProtocolMetadata : NativeObject {
internal SecProtocolMetadata (NativeHandle handle, bool owns) : base (handle, owns) { }

#if !COREBUILD
[ObsoletedOSPlatform ("ios18.5")]
[ObsoletedOSPlatform ("tvos18.5")]
[ObsoletedOSPlatform ("maccatalyst18.5")]
[ObsoletedOSPlatform ("macos15.5")]
[DllImport (Constants.SecurityLibrary)]
extern static IntPtr sec_protocol_metadata_get_negotiated_protocol (IntPtr handle);

/// <summary>To be added.</summary>
/// <value>To be added.</value>
/// <remarks>To be added.</remarks>
public string? NegotiatedProtocol => Marshal.PtrToStringAnsi (sec_protocol_metadata_get_negotiated_protocol (GetCheckedHandle ()));
[SupportedOSPlatform ("ios18.5")]
[SupportedOSPlatform ("tvos18.5")]
[SupportedOSPlatform ("maccatalyst18.5")]
[SupportedOSPlatform ("macos15.5")]
[DllImport (Constants.SecurityLibrary)]
extern static IntPtr sec_protocol_metadata_copy_negotiated_protocol (IntPtr handle);

/// <summary>Get the negotiated application protocol.</summary>
/// <value>The negotiated application protocol.</value>
public string? NegotiatedProtocol {
get {
if (!SystemVersion.IsAtLeastXcode16_4)
return Marshal.PtrToStringAnsi (sec_protocol_metadata_get_negotiated_protocol (GetCheckedHandle ()));

var rv = sec_protocol_metadata_copy_negotiated_protocol (GetCheckedHandle ());
var str = Marshal.PtrToStringUTF8 (rv);
unsafe {
NativeMemory.Free ((void*) rv);
}
return str;
}
}

[DllImport (Constants.SecurityLibrary)]
extern static IntPtr sec_protocol_metadata_copy_peer_public_key (IntPtr handle);
Expand Down Expand Up @@ -302,14 +324,37 @@ public void SetSignatureAlgorithmsForPeerHandler (Action<ushort> callback)
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("ios18.5")]
[ObsoletedOSPlatform ("tvos18.5")]
[ObsoletedOSPlatform ("maccatalyst18.5")]
[ObsoletedOSPlatform ("macos15.5")]
[DllImport (Constants.SecurityLibrary)]
static extern /* const char* */ IntPtr sec_protocol_metadata_get_server_name (IntPtr /* sec_protocol_metadata_t */ handle);

[SupportedOSPlatform ("ios18.5")]
[SupportedOSPlatform ("tvos18.5")]
[SupportedOSPlatform ("maccatalyst18.5")]
[SupportedOSPlatform ("macos15.5")]
[DllImport (Constants.SecurityLibrary)]
static extern /* const char* */ IntPtr sec_protocol_metadata_copy_server_name (IntPtr /* sec_protocol_metadata_t */ handle);

[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("maccatalyst")]
public string? ServerName => Marshal.PtrToStringAnsi (sec_protocol_metadata_get_server_name (GetCheckedHandle ()));
public string? ServerName {
get {
if (!SystemVersion.IsAtLeastXcode16_4)
return Marshal.PtrToStringAnsi (sec_protocol_metadata_get_server_name (GetCheckedHandle ()));

var rv = sec_protocol_metadata_copy_server_name (GetCheckedHandle ());
var str = Marshal.PtrToStringUTF8 (rv);
unsafe {
NativeMemory.Free ((void*) rv);
}
return str;
}
}

[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos")]
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-Security.todo

This file was deleted.

4 changes: 0 additions & 4 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-Security.todo

This file was deleted.

4 changes: 0 additions & 4 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-Security.todo

This file was deleted.

Loading