[Security] Add Support for DotNet Attributes Part 2 (#12520)

This commit is contained in:
TJ Lambert 2021-08-31 16:32:38 -05:00 коммит произвёл GitHub
Родитель 4274f1d6c0
Коммит e3e94d7cab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 429 добавлений и 8 удалений

Просмотреть файл

@ -14,13 +14,20 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
namespace Security {
#if !NET
[TV (12,0), Mac (10,14), iOS (12,0), Watch (5,0)]
#else
[SupportedOSPlatform ("ios12.0")]
[SupportedOSPlatform ("tvos12.0")]
[SupportedOSPlatform ("macos10.14")]
#endif
public class SecIdentity2 : NativeObject {
internal SecIdentity2 (IntPtr handle) : base (handle, false) {}
public SecIdentity2 (IntPtr handle, bool owns) : base (handle, owns) {}
@ -70,7 +77,13 @@ namespace Security {
}
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
[return: MarshalAs (UnmanagedType.I1)]
static extern bool sec_identity_access_certificates (IntPtr identity, ref BlockLiteral block);
@ -86,7 +99,13 @@ namespace Security {
del (new SecCertificate2 (cert, false));
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
// no [Async] as it can be called multiple times
[BindingImpl (BindingImplOptions.Optimizable)]
public bool AccessCertificates (Action</* sec_identity_t */SecCertificate2> handler)

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using CoreFoundation;
using Foundation;
@ -17,33 +18,45 @@ namespace Security {
public partial class SecPolicy {
#if !NET
[iOS (7,0)]
#endif
[DllImport (Constants.SecurityLibrary)]
extern static IntPtr /* __nullable CFDictionaryRef */ SecPolicyCopyProperties (IntPtr /* SecPolicyRef */ policyRef);
#if !NET
[iOS (7,0)]
#endif
public NSDictionary GetProperties ()
{
var dict = SecPolicyCopyProperties (Handle);
return Runtime.GetNSObject<NSDictionary> (dict, true);
}
#if !NET
[Mac (10,9)]
#endif
[DllImport (Constants.SecurityLibrary)]
extern static IntPtr /* __nullable SecPolicyRef */ SecPolicyCreateRevocation (/* CFOptionFlags */ nuint revocationFlags);
#if !NET
[Mac (10,9)][iOS (7,0)]
#endif
static public SecPolicy CreateRevocationPolicy (SecRevocation revocationFlags)
{
var policy = SecPolicyCreateRevocation ((nuint)(ulong) revocationFlags);
return policy == IntPtr.Zero ? null : new SecPolicy (policy, true);
}
#if !NET
[Mac (10,9)][iOS (7,0)]
#endif
[DllImport (Constants.SecurityLibrary)]
extern static IntPtr /* __nullable SecPolicyRef */ SecPolicyCreateWithProperties (IntPtr /* CFTypeRef */ policyIdentifier, IntPtr /* CFDictionaryRef */ properties);
#if !NET
[Mac (10,9)][iOS (7,0)]
#endif
static public SecPolicy CreatePolicy (NSString policyIdentifier, NSDictionary properties)
{
if (policyIdentifier == null)

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
@ -17,7 +18,13 @@ using sec_protocol_metadata_t=System.IntPtr;
using dispatch_queue_t=System.IntPtr;
namespace Security {
#if !NET
[TV (12,0), Mac (10,14), iOS (12,0), Watch (5,0)]
#else
[SupportedOSPlatform ("ios12.0")]
[SupportedOSPlatform ("tvos12.0")]
[SupportedOSPlatform ("macos10.14")]
#endif
public class SecProtocolMetadata : NativeObject {
internal SecProtocolMetadata (IntPtr handle) : base (handle, false) {}
@ -36,44 +43,120 @@ namespace Security {
public DispatchData PeerPublicKey => CreateDispatchData (sec_protocol_metadata_copy_peer_public_key (GetCheckedHandle ()));
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'NegotiatedTlsProtocolVersion' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'NegotiatedTlsProtocolVersion' instead.' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'NegotiatedTlsProtocolVersion' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
extern static SslProtocol sec_protocol_metadata_get_negotiated_protocol_version (IntPtr handle);
#if !NET
[Deprecated(PlatformName.MacOSX, 10, 15, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
[Deprecated(PlatformName.iOS, 13, 0, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
[Deprecated(PlatformName.WatchOS, 6, 0, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
[Deprecated(PlatformName.TvOS, 13, 0, message: "Use 'NegotiatedTlsProtocolVersion' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'NegotiatedTlsProtocolVersion' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'NegotiatedTlsProtocolVersion' instead.' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'NegotiatedTlsProtocolVersion' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public SslProtocol NegotiatedProtocolVersion => sec_protocol_metadata_get_negotiated_protocol_version (GetCheckedHandle ());
#if !NET
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern TlsProtocolVersion sec_protocol_metadata_get_negotiated_tls_protocol_version (IntPtr handle);
#if !NET
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public TlsProtocolVersion NegotiatedTlsProtocolVersion => sec_protocol_metadata_get_negotiated_tls_protocol_version (GetCheckedHandle ());
#if !NET
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern TlsCipherSuite sec_protocol_metadata_get_negotiated_tls_ciphersuite (IntPtr handle);
#if !NET
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public TlsCipherSuite NegotiatedTlsCipherSuite => sec_protocol_metadata_get_negotiated_tls_ciphersuite (GetCheckedHandle ());
[DllImport (Constants.SecurityLibrary)]
[Deprecated (PlatformName.iOS, 13,0)]
[Deprecated (PlatformName.TvOS, 13,0)]
[Deprecated (PlatformName.WatchOS, 6,0)]
[Deprecated (PlatformName.MacOSX, 10,15)]
extern static SslCipherSuite sec_protocol_metadata_get_negotiated_ciphersuite (IntPtr handle);
#if !NET
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'NegotiatedTlsCipherSuite' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'NegotiatedTlsCipherSuite' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'NegotiatedTlsCipherSuite' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
extern static SslCipherSuite sec_protocol_metadata_get_negotiated_ciphersuite (IntPtr handle);
#if !NET
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'NegotiatedTlsCipherSuite' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'NegotiatedTlsCipherSuite' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'NegotiatedTlsCipherSuite' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'NegotiatedTlsCipherSuite' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public SslCipherSuite NegotiatedCipherSuite => sec_protocol_metadata_get_negotiated_ciphersuite (GetCheckedHandle ());
[DllImport (Constants.SecurityLibrary)]
@ -276,14 +359,32 @@ namespace Security {
return handle == IntPtr.Zero ? null : new DispatchData (handle, owns: true);
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern /* const char* */ IntPtr sec_protocol_metadata_get_server_name (IntPtr /* sec_protocol_metadata_t */ handle);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public string ServerName => Marshal.PtrToStringAnsi (sec_protocol_metadata_get_server_name (GetCheckedHandle ()));
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
[return: MarshalAs (UnmanagedType.U1)]
static extern bool sec_protocol_metadata_access_pre_shared_keys (IntPtr /* sec_protocol_metadata_t */ handle, ref BlockLiteral block);
@ -301,7 +402,13 @@ namespace Security {
del (CreateDispatchData (psk), CreateDispatchData (psk_identity));
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
// no [Async] as it can be called multiple times
[BindingImpl (BindingImplOptions.Optimizable)]
public bool AccessPreSharedKeys (SecAccessPreSharedKeysHandler handler)

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
@ -19,7 +20,13 @@ using sec_identity_t=System.IntPtr;
namespace Security {
#if !NET
[TV (12,0), Mac (10,14), iOS (12,0), Watch (5,0)]
#else
[SupportedOSPlatform ("ios12.0")]
[SupportedOSPlatform ("tvos12.0")]
[SupportedOSPlatform ("macos10.14")]
#endif
public class SecProtocolOptions : NativeObject {
#if !COREBUILD
// This type is only ever surfaced in response to callbacks in TLS/Network and documented as read-only
@ -36,116 +43,319 @@ namespace Security {
sec_protocol_options_set_local_identity (GetCheckedHandle (), identity.GetCheckedHandle ());
}
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'AddTlsCipherSuite (TlsCipherSuite)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'AddTlsCipherSuite (TlsCipherSuite)' instead.' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'AddTlsCipherSuite (TlsCipherSuite)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_add_tls_ciphersuite (sec_protocol_options_t handle, SslCipherSuite cipherSuite);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'AddTlsCipherSuite (TlsCipherSuite)' instead.")]
[Unavailable (PlatformName.MacCatalyst)]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
[UnsupportedOSPlatform ("maccatalyst")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'AddTlsCipherSuite (TlsCipherSuite)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'AddTlsCipherSuite (TlsCipherSuite)' instead.' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'AddTlsCipherSuite (TlsCipherSuite)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public void AddTlsCipherSuite (SslCipherSuite cipherSuite) => sec_protocol_options_add_tls_ciphersuite (GetCheckedHandle (), cipherSuite);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_append_tls_ciphersuite (sec_protocol_options_t options, TlsCipherSuite ciphersuite);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public void AddTlsCipherSuite (TlsCipherSuite cipherSuite) => sec_protocol_options_append_tls_ciphersuite (GetCheckedHandle (), cipherSuite);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_add_tls_ciphersuite_group (sec_protocol_options_t handle, SslCipherSuiteGroup cipherSuiteGroup);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'AddTlsCipherSuiteGroup (TlsCipherSuiteGroup)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public void AddTlsCipherSuiteGroup (SslCipherSuiteGroup cipherSuiteGroup) => sec_protocol_options_add_tls_ciphersuite_group (GetCheckedHandle (), cipherSuiteGroup);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_append_tls_ciphersuite_group (sec_protocol_options_t options, TlsCipherSuiteGroup group);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public void AddTlsCipherSuiteGroup (TlsCipherSuiteGroup cipherSuiteGroup) => sec_protocol_options_append_tls_ciphersuite_group (GetCheckedHandle (), cipherSuiteGroup);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'SetTlsMinVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'SetTlsMinVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'SetTlsMinVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_set_tls_min_version (sec_protocol_options_t handle, SslProtocol protocol);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'SetTlsMinVersion (TlsProtocolVersion)' instead.")]
[Unavailable (PlatformName.MacCatalyst)]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
[UnsupportedOSPlatform ("maccatalyst")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'SetTlsMinVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'SetTlsMinVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'SetTlsMinVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public void SetTlsMinVersion (SslProtocol protocol) => sec_protocol_options_set_tls_min_version (GetCheckedHandle (), protocol);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_set_min_tls_protocol_version (sec_protocol_options_t handle, TlsProtocolVersion version);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public void SetTlsMinVersion (TlsProtocolVersion protocol) => sec_protocol_options_set_min_tls_protocol_version (GetCheckedHandle (), protocol);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_set_tls_max_version (sec_protocol_options_t handle, SslProtocol protocol);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.")]
[Unavailable (PlatformName.MacCatalyst)]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
[UnsupportedOSPlatform ("maccatalyst")]
#if IOS
[Obsolete ("Starting with ios13.0 use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use 'SetTlsMaxVersion (TlsProtocolVersion)' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public void SetTlsMaxVersion (SslProtocol protocol) => sec_protocol_options_set_tls_max_version (GetCheckedHandle (), protocol);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_set_max_tls_protocol_version (sec_protocol_options_t handle, TlsProtocolVersion version);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public void SetTlsMaxVersion (TlsProtocolVersion protocol) => sec_protocol_options_set_max_tls_protocol_version (GetCheckedHandle (), protocol);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern TlsProtocolVersion sec_protocol_options_get_default_min_dtls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
static public TlsProtocolVersion DefaultMinDtlsProtocolVersion => sec_protocol_options_get_default_min_dtls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern TlsProtocolVersion sec_protocol_options_get_default_max_dtls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
static public TlsProtocolVersion DefaultMaxDtlsProtocolVersion => sec_protocol_options_get_default_max_dtls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern TlsProtocolVersion sec_protocol_options_get_default_min_tls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
static public TlsProtocolVersion DefaultMinTlsProtocolVersion => sec_protocol_options_get_default_min_tls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern TlsProtocolVersion sec_protocol_options_get_default_max_tls_protocol_version ();
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
static public TlsProtocolVersion DefaultMaxTlsProtocolVersion => sec_protocol_options_get_default_max_tls_protocol_version ();
[DllImport (Constants.SecurityLibrary)]
@ -168,17 +378,43 @@ namespace Security {
sec_protocol_options_set_tls_server_name (GetCheckedHandle (), serverName);
}
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use non-DHE cipher suites instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use non-DHE cipher suites instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use non-DHE cipher suites instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use non-DHE cipher suites instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use non-DHE cipher suites instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use non-DHE cipher suites instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use non-DHE cipher suites instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_set_tls_diffie_hellman_parameters (IntPtr handle, IntPtr dispatchDataParameter);
#if !NET
[Deprecated (PlatformName.MacOSX, 10,15, message: "Use non-DHE cipher suites instead.")]
[Deprecated (PlatformName.iOS, 13,0, message: "Use non-DHE cipher suites instead.")]
[Deprecated (PlatformName.WatchOS, 6,0, message: "Use non-DHE cipher suites instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message: "Use non-DHE cipher suites instead.")]
#else
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("macos10.15")]
#if IOS
[Obsolete ("Starting with ios13.0 use non-DHE cipher suites instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos13.0 use non-DHE cipher suites instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.15 use non-DHE cipher suites instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public void SetTlsDiffieHellmanParameters (DispatchData parameters)
{
if (parameters == null)
@ -254,13 +490,25 @@ namespace Security {
block_handler.CleanupBlock ();
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
[return: MarshalAs (UnmanagedType.I1)]
static extern bool sec_protocol_options_are_equal (sec_protocol_options_t optionsA, sec_protocol_options_t optionsB);
// Equatable would be nice but would fail on earlier OS versions
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public bool IsEqual (SecProtocolOptions other)
{
if (other == null)
@ -268,7 +516,13 @@ namespace Security {
return sec_protocol_options_are_equal (GetCheckedHandle (), other.Handle);
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
static public bool IsEqual (SecProtocolOptions optionsA, SecProtocolOptions optionsB)
{
if (optionsA == null)
@ -278,11 +532,23 @@ namespace Security {
return sec_protocol_options_are_equal (optionsA.Handle, optionsB.Handle);
}
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern void sec_protocol_options_set_tls_pre_shared_key_identity_hint (sec_protocol_options_t options, IntPtr /* dispatch_data */ psk_identity_hint);
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public void SetTlsPreSharedKeyIdentityHint (DispatchData pskIdentityHint)
{
if (pskIdentityHint == null)

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using CoreFoundation;
@ -63,9 +64,14 @@ namespace Security {
}
}
[DllImport (Constants.SecurityLibrary)]
#if !NET
[Deprecated (PlatformName.iOS, 14,0)]
[Deprecated (PlatformName.MacOSX, 11,0)]
[DllImport (Constants.SecurityLibrary)]
#else
[UnsupportedOSPlatform ("ios14.0")]
[UnsupportedOSPlatform ("macos11.0")]
#endif
extern static void SecRequestSharedWebCredential ( IntPtr /* CFStringRef */ fqdn, IntPtr /* CFStringRef */ account,
IntPtr /* void (^completionHandler)( CFArrayRef credentials, CFErrorRef error) */ completionHandler);
@ -96,8 +102,18 @@ namespace Security {
}
#endif
#if !NET
[Deprecated (PlatformName.iOS, 14,0, message: "Use 'ASAuthorizationPasswordRequest' instead.")]
[Deprecated (PlatformName.MacOSX, 11,0, message: "Use 'ASAuthorizationPasswordRequest' instead.")]
#else
[UnsupportedOSPlatform ("ios14.0")]
[UnsupportedOSPlatform ("macos11.0")]
#if IOS
[Obsolete ("Starting with ios14.0 use 'ASAuthorizationPasswordRequest' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos11.0 use 'ASAuthorizationPasswordRequest' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[BindingImpl (BindingImplOptions.Optimizable)]
public static void RequestSharedWebCredential (string domainName, string account, Action<SecSharedCredentialInfo[], NSError> handler)
{