Skip to content

Commit e3c1761

Browse files
authored
[Security] Update bindings to Xcode 26 beta 1-7. (#23714)
1 parent eb0ba37 commit e3c1761

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

src/Security/SecIdentity.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,33 @@ public SecKey PrivateKey {
3939
return new SecKey (p, true);
4040
}
4141
}
42+
43+
[SupportedOSPlatform ("ios26.0")]
44+
[SupportedOSPlatform ("maccatalyst26.0")]
45+
[SupportedOSPlatform ("macos26.0")]
46+
[SupportedOSPlatform ("tvos26.0")]
47+
[DllImport (Constants.SecurityLibrary)]
48+
extern static /* __nullable CF_RETURNS_RETAINED SecIdentityRef */ IntPtr SecIdentityCreate (
49+
IntPtr /* CFAllocatorRef __nullable */ allocator,
50+
IntPtr /* SecCertificateRef */ certificate,
51+
IntPtr /* SecKeyRef */ privateKey);
52+
53+
/// <summary>Create a <see cref="SecIdentity" /> instance from a certificate and a private key.</summary>
54+
/// <param name="certificate">The certificate to use for the new <see cref="SecIdentity" /> instance.</param>
55+
/// <param name="privateKey">The private to use for the new <see cref="SecIdentity" /> instance.</param>
56+
/// <returns>A new <see cref="SecIdentity" /> instance if successful, otherwise <see langword="null" />.</returns>
57+
[SupportedOSPlatform ("ios26.0")]
58+
[SupportedOSPlatform ("maccatalyst26.0")]
59+
[SupportedOSPlatform ("macos26.0")]
60+
[SupportedOSPlatform ("tvos26.0")]
61+
public static SecIdentity? Create (SecCertificate certificate, SecKey privateKey)
62+
{
63+
var rv = SecIdentityCreate (IntPtr.Zero, certificate.GetNonNullHandle (nameof (certificate)), privateKey.GetNonNullHandle (nameof (privateKey)));
64+
GC.KeepAlive (certificate);
65+
GC.KeepAlive (privateKey);
66+
if (rv == IntPtr.Zero)
67+
return null;
68+
return new SecIdentity (rv, true /* CF_RETURNS_RETAINED */);
69+
}
4270
}
4371
}

tests/monotouch-test/Security/IdentityTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ static public SecIdentity GetIdentity ()
3131
}
3232
}
3333

34+
[Test]
35+
public void Create ()
36+
{
37+
TestRuntime.AssertXcodeVersion (26, 0);
38+
39+
using var identity = GetIdentity ();
40+
using var newIdentity = SecIdentity.Create (identity.Certificate, identity.PrivateKey);
41+
Assert.That (newIdentity, Is.Not.Null, "new identity");
42+
}
43+
3444
[Test]
3545
public void Identity ()
3646
{

tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-Security.todo

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/xtro-sharpie/api-annotations-dotnet/iOS-Security.todo

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/xtro-sharpie/api-annotations-dotnet/macOS-Security.todo

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/xtro-sharpie/api-annotations-dotnet/tvOS-Security.todo

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)