objc2_security/generated/
SecureTransport.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/security/sslcontext?language=objc)
14#[doc(alias = "SSLContextRef")]
15#[repr(C)]
16pub struct SSLContext {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl SSLContext {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"SSLContext"> for SSLContext {}
27);
28
29/// [Apple's documentation](https://developer.apple.com/documentation/security/sslconnectionref?language=objc)
30pub type SSLConnectionRef = *const c_void;
31
32/// [Apple's documentation](https://developer.apple.com/documentation/security/sslsessionoption?language=objc)
33// NS_ENUM
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct SSLSessionOption(pub c_int);
37impl SSLSessionOption {
38    #[doc(alias = "kSSLSessionOptionBreakOnServerAuth")]
39    #[deprecated]
40    pub const BreakOnServerAuth: Self = Self(0);
41    #[doc(alias = "kSSLSessionOptionBreakOnCertRequested")]
42    #[deprecated]
43    pub const BreakOnCertRequested: Self = Self(1);
44    #[doc(alias = "kSSLSessionOptionBreakOnClientAuth")]
45    #[deprecated]
46    pub const BreakOnClientAuth: Self = Self(2);
47    #[doc(alias = "kSSLSessionOptionFalseStart")]
48    #[deprecated]
49    pub const FalseStart: Self = Self(3);
50    #[doc(alias = "kSSLSessionOptionSendOneByteRecord")]
51    #[deprecated]
52    pub const SendOneByteRecord: Self = Self(4);
53    #[doc(alias = "kSSLSessionOptionAllowServerIdentityChange")]
54    #[deprecated]
55    pub const AllowServerIdentityChange: Self = Self(5);
56    #[doc(alias = "kSSLSessionOptionFallback")]
57    #[deprecated]
58    pub const Fallback: Self = Self(6);
59    #[doc(alias = "kSSLSessionOptionBreakOnClientHello")]
60    #[deprecated]
61    pub const BreakOnClientHello: Self = Self(7);
62    #[doc(alias = "kSSLSessionOptionAllowRenegotiation")]
63    #[deprecated]
64    pub const AllowRenegotiation: Self = Self(8);
65    #[doc(alias = "kSSLSessionOptionEnableSessionTickets")]
66    #[deprecated]
67    pub const EnableSessionTickets: Self = Self(9);
68}
69
70#[cfg(feature = "objc2")]
71unsafe impl Encode for SSLSessionOption {
72    const ENCODING: Encoding = c_int::ENCODING;
73}
74
75#[cfg(feature = "objc2")]
76unsafe impl RefEncode for SSLSessionOption {
77    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
78}
79
80/// [Apple's documentation](https://developer.apple.com/documentation/security/sslsessionstate?language=objc)
81// NS_CLOSED_ENUM
82#[repr(i32)] // c_int
83#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
84pub enum SSLSessionState {
85    #[doc(alias = "kSSLIdle")]
86    #[deprecated]
87    Idle = 0,
88    #[doc(alias = "kSSLHandshake")]
89    #[deprecated]
90    Handshake = 1,
91    #[doc(alias = "kSSLConnected")]
92    #[deprecated]
93    Connected = 2,
94    #[doc(alias = "kSSLClosed")]
95    #[deprecated]
96    Closed = 3,
97    #[doc(alias = "kSSLAborted")]
98    #[deprecated]
99    Aborted = 4,
100}
101
102#[cfg(feature = "objc2")]
103unsafe impl Encode for SSLSessionState {
104    const ENCODING: Encoding = c_int::ENCODING;
105}
106
107#[cfg(feature = "objc2")]
108unsafe impl RefEncode for SSLSessionState {
109    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
110}
111
112/// [Apple's documentation](https://developer.apple.com/documentation/security/sslclientcertificatestate?language=objc)
113// NS_ENUM
114#[repr(transparent)]
115#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
116pub struct SSLClientCertificateState(pub c_int);
117impl SSLClientCertificateState {
118    #[doc(alias = "kSSLClientCertNone")]
119    #[deprecated]
120    pub const CertNone: Self = Self(0);
121    #[doc(alias = "kSSLClientCertRequested")]
122    #[deprecated]
123    pub const CertRequested: Self = Self(1);
124    #[doc(alias = "kSSLClientCertSent")]
125    #[deprecated]
126    pub const CertSent: Self = Self(2);
127    #[doc(alias = "kSSLClientCertRejected")]
128    #[deprecated]
129    pub const CertRejected: Self = Self(3);
130}
131
132#[cfg(feature = "objc2")]
133unsafe impl Encode for SSLClientCertificateState {
134    const ENCODING: Encoding = c_int::ENCODING;
135}
136
137#[cfg(feature = "objc2")]
138unsafe impl RefEncode for SSLClientCertificateState {
139    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
140}
141
142/// [Apple's documentation](https://developer.apple.com/documentation/security/sslreadfunc?language=objc)
143pub type SSLReadFunc = Option<
144    unsafe extern "C-unwind" fn(SSLConnectionRef, NonNull<c_void>, NonNull<usize>) -> OSStatus,
145>;
146
147/// [Apple's documentation](https://developer.apple.com/documentation/security/sslwritefunc?language=objc)
148pub type SSLWriteFunc = Option<
149    unsafe extern "C-unwind" fn(SSLConnectionRef, NonNull<c_void>, NonNull<usize>) -> OSStatus,
150>;
151
152/// [Apple's documentation](https://developer.apple.com/documentation/security/sslprotocolside?language=objc)
153// NS_CLOSED_ENUM
154#[repr(i32)] // c_int
155#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
156pub enum SSLProtocolSide {
157    #[doc(alias = "kSSLServerSide")]
158    #[deprecated]
159    ServerSide = 0,
160    #[doc(alias = "kSSLClientSide")]
161    #[deprecated]
162    ClientSide = 1,
163}
164
165#[cfg(feature = "objc2")]
166unsafe impl Encode for SSLProtocolSide {
167    const ENCODING: Encoding = c_int::ENCODING;
168}
169
170#[cfg(feature = "objc2")]
171unsafe impl RefEncode for SSLProtocolSide {
172    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
173}
174
175/// [Apple's documentation](https://developer.apple.com/documentation/security/sslconnectiontype?language=objc)
176// NS_ENUM
177#[repr(transparent)]
178#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
179pub struct SSLConnectionType(pub c_int);
180impl SSLConnectionType {
181    #[doc(alias = "kSSLStreamType")]
182    #[deprecated]
183    pub const StreamType: Self = Self(0);
184    #[doc(alias = "kSSLDatagramType")]
185    #[deprecated]
186    pub const DatagramType: Self = Self(1);
187}
188
189#[cfg(feature = "objc2")]
190unsafe impl Encode for SSLConnectionType {
191    const ENCODING: Encoding = c_int::ENCODING;
192}
193
194#[cfg(feature = "objc2")]
195unsafe impl RefEncode for SSLConnectionType {
196    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
197}
198
199extern "C" {
200    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_default?language=objc)
201    #[deprecated = "No longer supported. Use Network.framework."]
202    pub static kSSLSessionConfig_default: &'static CFString;
203}
204
205extern "C" {
206    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_atsv1?language=objc)
207    #[deprecated = "No longer supported. Use Network.framework."]
208    pub static kSSLSessionConfig_ATSv1: &'static CFString;
209}
210
211extern "C" {
212    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_atsv1_nopfs?language=objc)
213    #[deprecated = "No longer supported. Use Network.framework."]
214    pub static kSSLSessionConfig_ATSv1_noPFS: &'static CFString;
215}
216
217extern "C" {
218    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_standard?language=objc)
219    #[deprecated = "No longer supported. Use Network.framework."]
220    pub static kSSLSessionConfig_standard: &'static CFString;
221}
222
223extern "C" {
224    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_rc4_fallback?language=objc)
225    #[deprecated = "No longer supported. Use Network.framework."]
226    pub static kSSLSessionConfig_RC4_fallback: &'static CFString;
227}
228
229extern "C" {
230    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_tlsv1_fallback?language=objc)
231    #[deprecated = "No longer supported. Use Network.framework."]
232    pub static kSSLSessionConfig_TLSv1_fallback: &'static CFString;
233}
234
235extern "C" {
236    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_tlsv1_rc4_fallback?language=objc)
237    #[deprecated = "No longer supported. Use Network.framework."]
238    pub static kSSLSessionConfig_TLSv1_RC4_fallback: &'static CFString;
239}
240
241extern "C" {
242    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_legacy?language=objc)
243    #[deprecated = "No longer supported. Use Network.framework."]
244    pub static kSSLSessionConfig_legacy: &'static CFString;
245}
246
247extern "C" {
248    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_legacy_dhe?language=objc)
249    #[deprecated = "No longer supported. Use Network.framework."]
250    pub static kSSLSessionConfig_legacy_DHE: &'static CFString;
251}
252
253extern "C" {
254    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_anonymous?language=objc)
255    #[deprecated = "No longer supported. Use Network.framework."]
256    pub static kSSLSessionConfig_anonymous: &'static CFString;
257}
258
259extern "C" {
260    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_3des_fallback?language=objc)
261    #[deprecated = "No longer supported. Use Network.framework."]
262    pub static kSSLSessionConfig_3DES_fallback: &'static CFString;
263}
264
265extern "C" {
266    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksslsessionconfig_tlsv1_3des_fallback?language=objc)
267    #[deprecated = "No longer supported. Use Network.framework."]
268    pub static kSSLSessionConfig_TLSv1_3DES_fallback: &'static CFString;
269}
270
271unsafe impl ConcreteType for SSLContext {
272    #[doc(alias = "SSLContextGetTypeID")]
273    #[inline]
274    fn type_id() -> CFTypeID {
275        extern "C-unwind" {
276            fn SSLContextGetTypeID() -> CFTypeID;
277        }
278        unsafe { SSLContextGetTypeID() }
279    }
280}
281
282#[deprecated = "No longer supported. Use Network.framework."]
283#[inline]
284pub unsafe extern "C-unwind" fn SSLCreateContext(
285    alloc: Option<&CFAllocator>,
286    protocol_side: SSLProtocolSide,
287    connection_type: SSLConnectionType,
288) -> Option<CFRetained<SSLContext>> {
289    extern "C-unwind" {
290        fn SSLCreateContext(
291            alloc: Option<&CFAllocator>,
292            protocol_side: SSLProtocolSide,
293            connection_type: SSLConnectionType,
294        ) -> Option<NonNull<SSLContext>>;
295    }
296    let ret = unsafe { SSLCreateContext(alloc, protocol_side, connection_type) };
297    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
298}
299
300/// # Safety
301///
302/// `context_ptr` must be a valid pointer.
303#[deprecated = "No longer supported. Use Network.framework."]
304#[inline]
305pub unsafe extern "C-unwind" fn SSLNewContext(
306    is_server: bool,
307    context_ptr: NonNull<*mut SSLContext>,
308) -> OSStatus {
309    extern "C-unwind" {
310        fn SSLNewContext(is_server: Boolean, context_ptr: NonNull<*mut SSLContext>) -> OSStatus;
311    }
312    unsafe { SSLNewContext(is_server as _, context_ptr) }
313}
314
315extern "C-unwind" {
316    #[deprecated = "No longer supported. Use Network.framework."]
317    pub fn SSLDisposeContext(context: &SSLContext) -> OSStatus;
318}
319
320extern "C-unwind" {
321    /// # Safety
322    ///
323    /// `state` must be a valid pointer.
324    #[deprecated = "No longer supported. Use Network.framework."]
325    pub fn SSLGetSessionState(context: &SSLContext, state: NonNull<SSLSessionState>) -> OSStatus;
326}
327
328#[deprecated = "No longer supported. Use Network.framework."]
329#[inline]
330pub unsafe extern "C-unwind" fn SSLSetSessionOption(
331    context: &SSLContext,
332    option: SSLSessionOption,
333    value: bool,
334) -> OSStatus {
335    extern "C-unwind" {
336        fn SSLSetSessionOption(
337            context: &SSLContext,
338            option: SSLSessionOption,
339            value: Boolean,
340        ) -> OSStatus;
341    }
342    unsafe { SSLSetSessionOption(context, option, value as _) }
343}
344
345extern "C-unwind" {
346    /// # Safety
347    ///
348    /// `value` must be a valid pointer.
349    #[deprecated = "No longer supported. Use Network.framework."]
350    pub fn SSLGetSessionOption(
351        context: &SSLContext,
352        option: SSLSessionOption,
353        value: NonNull<Boolean>,
354    ) -> OSStatus;
355}
356
357extern "C-unwind" {
358    /// # Safety
359    ///
360    /// - `read_func` must be implemented correctly.
361    /// - `write_func` must be implemented correctly.
362    #[deprecated = "No longer supported. Use Network.framework."]
363    pub fn SSLSetIOFuncs(
364        context: &SSLContext,
365        read_func: SSLReadFunc,
366        write_func: SSLWriteFunc,
367    ) -> OSStatus;
368}
369
370extern "C-unwind" {
371    #[deprecated = "No longer supported. Use Network.framework."]
372    pub fn SSLSetSessionConfig(context: &SSLContext, config: &CFString) -> OSStatus;
373}
374
375extern "C-unwind" {
376    #[cfg(feature = "SecProtocolTypes")]
377    #[deprecated = "No longer supported. Use Network.framework."]
378    pub fn SSLSetProtocolVersionMin(context: &SSLContext, min_version: SSLProtocol) -> OSStatus;
379}
380
381extern "C-unwind" {
382    /// # Safety
383    ///
384    /// `min_version` must be a valid pointer.
385    #[cfg(feature = "SecProtocolTypes")]
386    #[deprecated = "No longer supported. Use Network.framework."]
387    pub fn SSLGetProtocolVersionMin(
388        context: &SSLContext,
389        min_version: NonNull<SSLProtocol>,
390    ) -> OSStatus;
391}
392
393extern "C-unwind" {
394    #[cfg(feature = "SecProtocolTypes")]
395    #[deprecated = "No longer supported. Use Network.framework."]
396    pub fn SSLSetProtocolVersionMax(context: &SSLContext, max_version: SSLProtocol) -> OSStatus;
397}
398
399extern "C-unwind" {
400    /// # Safety
401    ///
402    /// `max_version` must be a valid pointer.
403    #[cfg(feature = "SecProtocolTypes")]
404    #[deprecated = "No longer supported. Use Network.framework."]
405    pub fn SSLGetProtocolVersionMax(
406        context: &SSLContext,
407        max_version: NonNull<SSLProtocol>,
408    ) -> OSStatus;
409}
410
411#[cfg(feature = "SecProtocolTypes")]
412#[deprecated = "No longer supported. Use Network.framework."]
413#[inline]
414pub unsafe extern "C-unwind" fn SSLSetProtocolVersionEnabled(
415    context: &SSLContext,
416    protocol: SSLProtocol,
417    enable: bool,
418) -> OSStatus {
419    extern "C-unwind" {
420        fn SSLSetProtocolVersionEnabled(
421            context: &SSLContext,
422            protocol: SSLProtocol,
423            enable: Boolean,
424        ) -> OSStatus;
425    }
426    unsafe { SSLSetProtocolVersionEnabled(context, protocol, enable as _) }
427}
428
429extern "C-unwind" {
430    /// # Safety
431    ///
432    /// `enable` must be a valid pointer.
433    #[cfg(feature = "SecProtocolTypes")]
434    #[deprecated = "No longer supported. Use Network.framework."]
435    pub fn SSLGetProtocolVersionEnabled(
436        context: &SSLContext,
437        protocol: SSLProtocol,
438        enable: NonNull<Boolean>,
439    ) -> OSStatus;
440}
441
442extern "C-unwind" {
443    #[cfg(feature = "SecProtocolTypes")]
444    #[deprecated = "No longer supported. Use Network.framework."]
445    pub fn SSLSetProtocolVersion(context: &SSLContext, version: SSLProtocol) -> OSStatus;
446}
447
448extern "C-unwind" {
449    /// # Safety
450    ///
451    /// `protocol` must be a valid pointer.
452    #[cfg(feature = "SecProtocolTypes")]
453    #[deprecated = "No longer supported. Use Network.framework."]
454    pub fn SSLGetProtocolVersion(context: &SSLContext, protocol: NonNull<SSLProtocol>) -> OSStatus;
455}
456
457extern "C-unwind" {
458    /// # Safety
459    ///
460    /// `cert_refs` generic must be of the correct type.
461    #[deprecated = "No longer supported. Use Network.framework."]
462    pub fn SSLSetCertificate(context: &SSLContext, cert_refs: Option<&CFArray>) -> OSStatus;
463}
464
465extern "C-unwind" {
466    /// # Safety
467    ///
468    /// `connection` must be a valid pointer or null.
469    #[deprecated = "No longer supported. Use Network.framework."]
470    pub fn SSLSetConnection(context: &SSLContext, connection: SSLConnectionRef) -> OSStatus;
471}
472
473extern "C-unwind" {
474    /// # Safety
475    ///
476    /// `connection` must be a valid pointer.
477    #[deprecated = "No longer supported. Use Network.framework."]
478    pub fn SSLGetConnection(
479        context: &SSLContext,
480        connection: NonNull<SSLConnectionRef>,
481    ) -> OSStatus;
482}
483
484extern "C-unwind" {
485    /// # Safety
486    ///
487    /// `peer_name` must be a valid pointer or null.
488    #[deprecated = "No longer supported. Use Network.framework."]
489    pub fn SSLSetPeerDomainName(
490        context: &SSLContext,
491        peer_name: *const c_char,
492        peer_name_len: usize,
493    ) -> OSStatus;
494}
495
496extern "C-unwind" {
497    /// # Safety
498    ///
499    /// `peer_name_len` must be a valid pointer.
500    #[deprecated = "No longer supported. Use Network.framework."]
501    pub fn SSLGetPeerDomainNameLength(
502        context: &SSLContext,
503        peer_name_len: NonNull<usize>,
504    ) -> OSStatus;
505}
506
507extern "C-unwind" {
508    /// # Safety
509    ///
510    /// - `peer_name` must be a valid pointer.
511    /// - `peer_name_len` must be a valid pointer.
512    #[deprecated = "No longer supported. Use Network.framework."]
513    pub fn SSLGetPeerDomainName(
514        context: &SSLContext,
515        peer_name: NonNull<c_char>,
516        peer_name_len: NonNull<usize>,
517    ) -> OSStatus;
518}
519
520extern "C-unwind" {
521    /// # Safety
522    ///
523    /// `peer_name_len` must be a valid pointer.
524    #[deprecated = "No longer supported. Use Network.framework."]
525    pub fn SSLCopyRequestedPeerNameLength(
526        ctx: &SSLContext,
527        peer_name_len: NonNull<usize>,
528    ) -> OSStatus;
529}
530
531extern "C-unwind" {
532    /// # Safety
533    ///
534    /// - `peer_name` must be a valid pointer.
535    /// - `peer_name_len` must be a valid pointer.
536    #[deprecated = "No longer supported. Use Network.framework."]
537    pub fn SSLCopyRequestedPeerName(
538        context: &SSLContext,
539        peer_name: NonNull<c_char>,
540        peer_name_len: NonNull<usize>,
541    ) -> OSStatus;
542}
543
544extern "C-unwind" {
545    /// # Safety
546    ///
547    /// `cookie` must be a valid pointer or null.
548    #[deprecated = "No longer supported. Use Network.framework."]
549    pub fn SSLSetDatagramHelloCookie(
550        dtls_context: &SSLContext,
551        cookie: *const c_void,
552        cookie_len: usize,
553    ) -> OSStatus;
554}
555
556extern "C-unwind" {
557    #[deprecated = "No longer supported. Use Network.framework."]
558    pub fn SSLSetMaxDatagramRecordSize(dtls_context: &SSLContext, max_size: usize) -> OSStatus;
559}
560
561extern "C-unwind" {
562    /// # Safety
563    ///
564    /// `max_size` must be a valid pointer.
565    #[deprecated = "No longer supported. Use Network.framework."]
566    pub fn SSLGetMaxDatagramRecordSize(
567        dtls_context: &SSLContext,
568        max_size: NonNull<usize>,
569    ) -> OSStatus;
570}
571
572extern "C-unwind" {
573    /// # Safety
574    ///
575    /// `protocol` must be a valid pointer.
576    #[cfg(feature = "SecProtocolTypes")]
577    #[deprecated = "No longer supported. Use Network.framework."]
578    pub fn SSLGetNegotiatedProtocolVersion(
579        context: &SSLContext,
580        protocol: NonNull<SSLProtocol>,
581    ) -> OSStatus;
582}
583
584extern "C-unwind" {
585    /// # Safety
586    ///
587    /// `num_ciphers` must be a valid pointer.
588    #[deprecated = "No longer supported. Use Network.framework."]
589    pub fn SSLGetNumberSupportedCiphers(
590        context: &SSLContext,
591        num_ciphers: NonNull<usize>,
592    ) -> OSStatus;
593}
594
595extern "C-unwind" {
596    /// # Safety
597    ///
598    /// - `ciphers` must be a valid pointer.
599    /// - `num_ciphers` must be a valid pointer.
600    #[cfg(feature = "CipherSuite")]
601    #[deprecated = "No longer supported. Use Network.framework."]
602    pub fn SSLGetSupportedCiphers(
603        context: &SSLContext,
604        ciphers: NonNull<SSLCipherSuite>,
605        num_ciphers: NonNull<usize>,
606    ) -> OSStatus;
607}
608
609extern "C-unwind" {
610    /// # Safety
611    ///
612    /// `num_ciphers` must be a valid pointer.
613    #[deprecated = "No longer supported. Use Network.framework."]
614    pub fn SSLGetNumberEnabledCiphers(
615        context: &SSLContext,
616        num_ciphers: NonNull<usize>,
617    ) -> OSStatus;
618}
619
620extern "C-unwind" {
621    /// # Safety
622    ///
623    /// `ciphers` must be a valid pointer.
624    #[cfg(feature = "CipherSuite")]
625    #[deprecated = "No longer supported. Use Network.framework."]
626    pub fn SSLSetEnabledCiphers(
627        context: &SSLContext,
628        ciphers: NonNull<SSLCipherSuite>,
629        num_ciphers: usize,
630    ) -> OSStatus;
631}
632
633extern "C-unwind" {
634    /// # Safety
635    ///
636    /// - `ciphers` must be a valid pointer.
637    /// - `num_ciphers` must be a valid pointer.
638    #[cfg(feature = "CipherSuite")]
639    #[deprecated = "No longer supported. Use Network.framework."]
640    pub fn SSLGetEnabledCiphers(
641        context: &SSLContext,
642        ciphers: NonNull<SSLCipherSuite>,
643        num_ciphers: NonNull<usize>,
644    ) -> OSStatus;
645}
646
647#[deprecated = "No longer supported. Use Network.framework."]
648#[inline]
649pub unsafe extern "C-unwind" fn SSLSetSessionTicketsEnabled(
650    context: &SSLContext,
651    enabled: bool,
652) -> OSStatus {
653    extern "C-unwind" {
654        fn SSLSetSessionTicketsEnabled(context: &SSLContext, enabled: Boolean) -> OSStatus;
655    }
656    unsafe { SSLSetSessionTicketsEnabled(context, enabled as _) }
657}
658
659#[deprecated = "No longer supported. Use Network.framework."]
660#[inline]
661pub unsafe extern "C-unwind" fn SSLSetEnableCertVerify(
662    context: &SSLContext,
663    enable_verify: bool,
664) -> OSStatus {
665    extern "C-unwind" {
666        fn SSLSetEnableCertVerify(context: &SSLContext, enable_verify: Boolean) -> OSStatus;
667    }
668    unsafe { SSLSetEnableCertVerify(context, enable_verify as _) }
669}
670
671extern "C-unwind" {
672    /// # Safety
673    ///
674    /// `enable_verify` must be a valid pointer.
675    #[deprecated = "No longer supported. Use Network.framework."]
676    pub fn SSLGetEnableCertVerify(
677        context: &SSLContext,
678        enable_verify: NonNull<Boolean>,
679    ) -> OSStatus;
680}
681
682#[deprecated = "No longer supported. Use Network.framework."]
683#[inline]
684pub unsafe extern "C-unwind" fn SSLSetAllowsExpiredCerts(
685    context: &SSLContext,
686    allows_expired: bool,
687) -> OSStatus {
688    extern "C-unwind" {
689        fn SSLSetAllowsExpiredCerts(context: &SSLContext, allows_expired: Boolean) -> OSStatus;
690    }
691    unsafe { SSLSetAllowsExpiredCerts(context, allows_expired as _) }
692}
693
694extern "C-unwind" {
695    /// # Safety
696    ///
697    /// `allows_expired` must be a valid pointer.
698    #[deprecated = "No longer supported. Use Network.framework."]
699    pub fn SSLGetAllowsExpiredCerts(
700        context: &SSLContext,
701        allows_expired: NonNull<Boolean>,
702    ) -> OSStatus;
703}
704
705#[deprecated = "No longer supported. Use Network.framework."]
706#[inline]
707pub unsafe extern "C-unwind" fn SSLSetAllowsExpiredRoots(
708    context: &SSLContext,
709    allows_expired: bool,
710) -> OSStatus {
711    extern "C-unwind" {
712        fn SSLSetAllowsExpiredRoots(context: &SSLContext, allows_expired: Boolean) -> OSStatus;
713    }
714    unsafe { SSLSetAllowsExpiredRoots(context, allows_expired as _) }
715}
716
717extern "C-unwind" {
718    /// # Safety
719    ///
720    /// `allows_expired` must be a valid pointer.
721    #[deprecated = "No longer supported. Use Network.framework."]
722    pub fn SSLGetAllowsExpiredRoots(
723        context: &SSLContext,
724        allows_expired: NonNull<Boolean>,
725    ) -> OSStatus;
726}
727
728#[deprecated = "No longer supported. Use Network.framework."]
729#[inline]
730pub unsafe extern "C-unwind" fn SSLSetAllowsAnyRoot(
731    context: &SSLContext,
732    any_root: bool,
733) -> OSStatus {
734    extern "C-unwind" {
735        fn SSLSetAllowsAnyRoot(context: &SSLContext, any_root: Boolean) -> OSStatus;
736    }
737    unsafe { SSLSetAllowsAnyRoot(context, any_root as _) }
738}
739
740extern "C-unwind" {
741    /// # Safety
742    ///
743    /// `any_root` must be a valid pointer.
744    #[deprecated = "No longer supported. Use Network.framework."]
745    pub fn SSLGetAllowsAnyRoot(context: &SSLContext, any_root: NonNull<Boolean>) -> OSStatus;
746}
747
748/// # Safety
749///
750/// `trusted_roots` generic must be of the correct type.
751#[deprecated = "No longer supported. Use Network.framework."]
752#[inline]
753pub unsafe extern "C-unwind" fn SSLSetTrustedRoots(
754    context: &SSLContext,
755    trusted_roots: &CFArray,
756    replace_existing: bool,
757) -> OSStatus {
758    extern "C-unwind" {
759        fn SSLSetTrustedRoots(
760            context: &SSLContext,
761            trusted_roots: &CFArray,
762            replace_existing: Boolean,
763        ) -> OSStatus;
764    }
765    unsafe { SSLSetTrustedRoots(context, trusted_roots, replace_existing as _) }
766}
767
768extern "C-unwind" {
769    /// # Safety
770    ///
771    /// `trusted_roots` must be a valid pointer.
772    #[deprecated = "No longer supported. Use Network.framework."]
773    pub fn SSLCopyTrustedRoots(
774        context: &SSLContext,
775        trusted_roots: NonNull<*const CFArray>,
776    ) -> OSStatus;
777}
778
779extern "C-unwind" {
780    /// # Safety
781    ///
782    /// `certs` must be a valid pointer.
783    #[deprecated = "No longer supported. Use Network.framework."]
784    pub fn SSLCopyPeerCertificates(
785        context: &SSLContext,
786        certs: NonNull<*const CFArray>,
787    ) -> OSStatus;
788}
789
790extern "C-unwind" {
791    /// # Safety
792    ///
793    /// `trust` must be a valid pointer.
794    #[cfg(feature = "SecTrust")]
795    #[deprecated = "No longer supported. Use Network.framework."]
796    pub fn SSLCopyPeerTrust(context: &SSLContext, trust: NonNull<*mut SecTrust>) -> OSStatus;
797}
798
799extern "C-unwind" {
800    /// # Safety
801    ///
802    /// `peer_id` must be a valid pointer or null.
803    #[deprecated = "No longer supported. Use Network.framework."]
804    pub fn SSLSetPeerID(
805        context: &SSLContext,
806        peer_id: *const c_void,
807        peer_id_len: usize,
808    ) -> OSStatus;
809}
810
811extern "C-unwind" {
812    /// # Safety
813    ///
814    /// - `peer_id` must be a valid pointer.
815    /// - `peer_id_len` must be a valid pointer.
816    #[deprecated = "No longer supported. Use Network.framework."]
817    pub fn SSLGetPeerID(
818        context: &SSLContext,
819        peer_id: NonNull<*const c_void>,
820        peer_id_len: NonNull<usize>,
821    ) -> OSStatus;
822}
823
824extern "C-unwind" {
825    /// # Safety
826    ///
827    /// `cipher_suite` must be a valid pointer.
828    #[cfg(feature = "CipherSuite")]
829    #[deprecated = "No longer supported. Use Network.framework."]
830    pub fn SSLGetNegotiatedCipher(
831        context: &SSLContext,
832        cipher_suite: NonNull<SSLCipherSuite>,
833    ) -> OSStatus;
834}
835
836extern "C-unwind" {
837    /// # Safety
838    ///
839    /// `protocols` generic must be of the correct type.
840    #[deprecated = "No longer supported. Use Network.framework."]
841    pub fn SSLSetALPNProtocols(context: &SSLContext, protocols: &CFArray) -> OSStatus;
842}
843
844extern "C-unwind" {
845    /// # Safety
846    ///
847    /// `protocols` must be a valid pointer.
848    #[deprecated = "No longer supported. Use Network.framework."]
849    pub fn SSLCopyALPNProtocols(
850        context: &SSLContext,
851        protocols: NonNull<*const CFArray>,
852    ) -> OSStatus;
853}
854
855extern "C-unwind" {
856    #[deprecated = "No longer supported. Use Network.framework."]
857    pub fn SSLSetOCSPResponse(context: &SSLContext, response: &CFData) -> OSStatus;
858}
859
860extern "C-unwind" {
861    /// # Safety
862    ///
863    /// `cert_refs` generic must be of the correct type.
864    #[deprecated = "No longer supported. Use Network.framework."]
865    pub fn SSLSetEncryptionCertificate(context: &SSLContext, cert_refs: &CFArray) -> OSStatus;
866}
867
868/// [Apple's documentation](https://developer.apple.com/documentation/security/sslauthenticate?language=objc)
869// NS_ENUM
870#[repr(transparent)]
871#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
872pub struct SSLAuthenticate(pub c_int);
873impl SSLAuthenticate {
874    #[doc(alias = "kNeverAuthenticate")]
875    pub const NeverAuthenticate: Self = Self(0);
876    #[doc(alias = "kAlwaysAuthenticate")]
877    pub const AlwaysAuthenticate: Self = Self(1);
878    #[doc(alias = "kTryAuthenticate")]
879    pub const TryAuthenticate: Self = Self(2);
880}
881
882#[cfg(feature = "objc2")]
883unsafe impl Encode for SSLAuthenticate {
884    const ENCODING: Encoding = c_int::ENCODING;
885}
886
887#[cfg(feature = "objc2")]
888unsafe impl RefEncode for SSLAuthenticate {
889    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
890}
891
892extern "C-unwind" {
893    #[deprecated = "No longer supported. Use Network.framework."]
894    pub fn SSLSetClientSideAuthenticate(context: &SSLContext, auth: SSLAuthenticate) -> OSStatus;
895}
896
897extern "C-unwind" {
898    /// # Safety
899    ///
900    /// `der_dn` must be a valid pointer or null.
901    #[deprecated = "No longer supported. Use Network.framework."]
902    pub fn SSLAddDistinguishedName(
903        context: &SSLContext,
904        der_dn: *const c_void,
905        der_dn_len: usize,
906    ) -> OSStatus;
907}
908
909/// # Safety
910///
911/// `certificate_or_array` should be of the correct type.
912#[deprecated = "No longer supported. Use Network.framework."]
913#[inline]
914pub unsafe extern "C-unwind" fn SSLSetCertificateAuthorities(
915    context: &SSLContext,
916    certificate_or_array: &CFType,
917    replace_existing: bool,
918) -> OSStatus {
919    extern "C-unwind" {
920        fn SSLSetCertificateAuthorities(
921            context: &SSLContext,
922            certificate_or_array: &CFType,
923            replace_existing: Boolean,
924        ) -> OSStatus;
925    }
926    unsafe { SSLSetCertificateAuthorities(context, certificate_or_array, replace_existing as _) }
927}
928
929extern "C-unwind" {
930    /// # Safety
931    ///
932    /// `certificates` must be a valid pointer.
933    #[deprecated = "No longer supported. Use Network.framework."]
934    pub fn SSLCopyCertificateAuthorities(
935        context: &SSLContext,
936        certificates: NonNull<*const CFArray>,
937    ) -> OSStatus;
938}
939
940extern "C-unwind" {
941    /// # Safety
942    ///
943    /// `names` must be a valid pointer.
944    #[deprecated = "No longer supported. Use Network.framework."]
945    pub fn SSLCopyDistinguishedNames(
946        context: &SSLContext,
947        names: NonNull<*const CFArray>,
948    ) -> OSStatus;
949}
950
951extern "C-unwind" {
952    /// # Safety
953    ///
954    /// `client_state` must be a valid pointer.
955    #[deprecated = "No longer supported. Use Network.framework."]
956    pub fn SSLGetClientCertificateState(
957        context: &SSLContext,
958        client_state: NonNull<SSLClientCertificateState>,
959    ) -> OSStatus;
960}
961
962extern "C-unwind" {
963    /// # Safety
964    ///
965    /// `dh_params` must be a valid pointer or null.
966    #[deprecated = "No longer supported. Use Network.framework."]
967    pub fn SSLSetDiffieHellmanParams(
968        context: &SSLContext,
969        dh_params: *const c_void,
970        dh_params_len: usize,
971    ) -> OSStatus;
972}
973
974extern "C-unwind" {
975    /// # Safety
976    ///
977    /// - `dh_params` must be a valid pointer.
978    /// - `dh_params_len` must be a valid pointer.
979    #[deprecated = "No longer supported. Use Network.framework."]
980    pub fn SSLGetDiffieHellmanParams(
981        context: &SSLContext,
982        dh_params: NonNull<*const c_void>,
983        dh_params_len: NonNull<usize>,
984    ) -> OSStatus;
985}
986
987#[deprecated = "No longer supported. Use Network.framework."]
988#[inline]
989pub unsafe extern "C-unwind" fn SSLSetRsaBlinding(
990    context: &SSLContext,
991    blinding: bool,
992) -> OSStatus {
993    extern "C-unwind" {
994        fn SSLSetRsaBlinding(context: &SSLContext, blinding: Boolean) -> OSStatus;
995    }
996    unsafe { SSLSetRsaBlinding(context, blinding as _) }
997}
998
999extern "C-unwind" {
1000    /// # Safety
1001    ///
1002    /// `blinding` must be a valid pointer.
1003    #[deprecated = "No longer supported. Use Network.framework."]
1004    pub fn SSLGetRsaBlinding(context: &SSLContext, blinding: NonNull<Boolean>) -> OSStatus;
1005}
1006
1007extern "C-unwind" {
1008    #[deprecated = "No longer supported. Use Network.framework."]
1009    pub fn SSLHandshake(context: &SSLContext) -> OSStatus;
1010}
1011
1012extern "C-unwind" {
1013    #[deprecated = "No longer supported. Use Network.framework."]
1014    pub fn SSLReHandshake(context: &SSLContext) -> OSStatus;
1015}
1016
1017extern "C-unwind" {
1018    /// # Safety
1019    ///
1020    /// - `data` must be a valid pointer or null.
1021    /// - `processed` must be a valid pointer.
1022    #[deprecated = "No longer supported. Use Network.framework."]
1023    pub fn SSLWrite(
1024        context: &SSLContext,
1025        data: *const c_void,
1026        data_length: usize,
1027        processed: NonNull<usize>,
1028    ) -> OSStatus;
1029}
1030
1031extern "C-unwind" {
1032    /// # Safety
1033    ///
1034    /// - `data` must be a valid pointer.
1035    /// - `processed` must be a valid pointer.
1036    #[deprecated = "No longer supported. Use Network.framework."]
1037    pub fn SSLRead(
1038        context: &SSLContext,
1039        data: NonNull<c_void>,
1040        data_length: usize,
1041        processed: NonNull<usize>,
1042    ) -> OSStatus;
1043}
1044
1045extern "C-unwind" {
1046    /// # Safety
1047    ///
1048    /// `buffer_size` must be a valid pointer.
1049    #[deprecated = "No longer supported. Use Network.framework."]
1050    pub fn SSLGetBufferedReadSize(context: &SSLContext, buffer_size: NonNull<usize>) -> OSStatus;
1051}
1052
1053extern "C-unwind" {
1054    /// # Safety
1055    ///
1056    /// `buf_size` must be a valid pointer.
1057    #[deprecated = "No longer supported. Use Network.framework."]
1058    pub fn SSLGetDatagramWriteSize(dtls_context: &SSLContext, buf_size: NonNull<usize>)
1059        -> OSStatus;
1060}
1061
1062extern "C-unwind" {
1063    #[deprecated = "No longer supported. Use Network.framework."]
1064    pub fn SSLClose(context: &SSLContext) -> OSStatus;
1065}
1066
1067extern "C-unwind" {
1068    #[deprecated = "No longer supported. Use Network.framework."]
1069    pub fn SSLSetError(context: &SSLContext, status: OSStatus) -> OSStatus;
1070}