2 * Copyright (c) 1999-2002,2005-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * SecureTransport.h - Public API for Apple SSL/TLS Implementation
28 #ifndef _SECURITY_SECURETRANSPORT_H_
29 #define _SECURITY_SECURETRANSPORT_H_
32 * This file describes the public API for an implementation of the
33 * Secure Socket Layer, V. 3.0, Transport Layer Security, V. 1.0 to V. 1.2
34 * and Datagram Transport Layer Security V. 1.0
36 * There are no transport layer dependencies in this library;
37 * it can be used with sockets, Open Transport, etc. Applications using
38 * this library provide callback functions which do the actual I/O
39 * on underlying network connections. Applications are also responsible
40 * for setting up raw network connections; the application passes in
41 * an opaque reference to the underlying (connected) entity at the
42 * start of an SSL session in the form of an SSLConnectionRef.
46 * A "client" is the initiator of an SSL Session. The canonical example
47 * of a client is a web browser, when it's talking to an https URL.
49 * A "server" is an entity which accepts requests for SSL sessions made
50 * by clients. E.g., a secure web server.
52 * An "SSL Session", or "session", is bounded by calls to SSLHandshake()
53 * and SSLClose(). An "Active session" is in some state between these
54 * two calls, inclusive.
56 * An SSL Session Context, or SSLContextRef, is an opaque reference in this
57 * library to the state associated with one session. A SSLContextRef cannot
58 * be reused for multiple sessions.
61 #include <CoreFoundation/CFArray.h>
62 #include <Security/CipherSuite.h>
63 #include <Security/SecTrust.h>
64 #include <sys/types.h>
65 #include <Availability.h>
71 CF_ASSUME_NONNULL_BEGIN
72 CF_IMPLICIT_BRIDGING_ENABLED
74 /***********************
75 *** Common typedefs ***
76 ***********************/
78 /* Opaque reference to an SSL session context */
80 typedef struct CF_BRIDGED_TYPE(id
) SSLContext
*SSLContextRef
;
82 /* Opaque reference to an I/O connection (socket, endpoint, etc.) */
83 typedef const void * SSLConnectionRef
;
85 /* SSL Protocol version */
86 typedef CF_ENUM(int, SSLProtocol
) {
87 kSSLProtocolUnknown
= 0, /* no protocol negotiated/specified; use default */
88 kSSLProtocol3
= 2, /* SSL 3.0 */
89 kTLSProtocol1
= 4, /* TLS 1.0 */
90 kTLSProtocol11
= 7, /* TLS 1.1 */
91 kTLSProtocol12
= 8, /* TLS 1.2 */
92 kDTLSProtocol1
= 9, /* DTLS 1.0 */
94 /* DEPRECATED on iOS */
95 kSSLProtocol2
= 1, /* SSL 2.0 */
96 kSSLProtocol3Only
= 3, /* SSL 3.0 Only */
97 kTLSProtocol1Only
= 5, /* TLS 1.0 Only */
98 kSSLProtocolAll
= 6, /* All TLS supported protocols */
102 /* SSL session options */
103 typedef CF_ENUM(int, SSLSessionOption
) {
105 * Set this option to enable returning from SSLHandshake (with a result of
106 * errSSLServerAuthCompleted) when the server authentication portion of the
107 * handshake is complete. This disable certificate verification and
108 * provides an opportunity to perform application-specific server
109 * verification before deciding to continue.
111 kSSLSessionOptionBreakOnServerAuth
= 0,
113 * Set this option to enable returning from SSLHandshake (with a result of
114 * errSSLClientCertRequested) when the server requests a client certificate.
116 kSSLSessionOptionBreakOnCertRequested
= 1,
118 * This option is the same as kSSLSessionOptionBreakOnServerAuth but applies
119 * to the case where SecureTransport is the server and the client has presented
120 * its certificates allowing the server to verify whether these should be
121 * allowed to authenticate.
123 kSSLSessionOptionBreakOnClientAuth
= 2,
125 * Enable/Disable TLS False Start
126 * When enabled, False Start will only be performed if a adequate cipher-suite is
129 kSSLSessionOptionFalseStart
= 3,
131 * Enable/Disable 1/n-1 record splitting for BEAST attack mitigation.
132 * When enabled, record splitting will only be performed for TLS 1.0 connections
133 * using a block cipher.
135 kSSLSessionOptionSendOneByteRecord
= 4,
137 * Allow/Disallow server identity change on renegotiation. Disallow by default
138 * to avoid Triple Handshake attack.
140 kSSLSessionOptionAllowServerIdentityChange
= 5,
142 * Enable fallback countermeasures. Use this option when retyring a SSL connection
143 * with a lower protocol version because of failure to connect.
145 kSSLSessionOptionFallback
= 6,
147 * Set this option to break from a client hello in order to check for SNI
149 kSSLSessionOptionBreakOnClientHello
= 7,
153 /* State of an SSLSession */
154 typedef CF_ENUM(int, SSLSessionState
) {
155 kSSLIdle
, /* no I/O performed yet */
156 kSSLHandshake
, /* SSL handshake in progress */
157 kSSLConnected
, /* Handshake complete, ready for normal I/O */
158 kSSLClosed
, /* connection closed normally */
159 kSSLAborted
/* connection aborted */
163 * Status of client certificate exchange (which is optional
164 * for both server and client).
166 typedef CF_ENUM(int, SSLClientCertificateState
) {
167 /* Server hasn't asked for a cert. Client hasn't sent one. */
169 /* Server has asked for a cert, but client didn't send it. */
170 kSSLClientCertRequested
,
172 * Server side: We asked for a cert, client sent one, we validated
173 * it OK. App can inspect the cert via
174 * SSLGetPeerCertificates().
175 * Client side: server asked for one, we sent it.
179 * Client sent a cert but failed validation. Server side only.
180 * Server app can inspect the cert via SSLGetPeerCertificates().
182 kSSLClientCertRejected
186 * R/W functions. The application using this library provides
187 * these functions via SSLSetIOFuncs().
189 * Data's memory is allocated by caller; on entry to these two functions
190 * the *length argument indicates both the size of the available data and the
191 * requested byte count. Number of bytes actually transferred is returned in
194 * The application may configure the underlying connection to operate
195 * in a non-blocking manner; in such a case, a read operation may
196 * well return errSSLWouldBlock, indicating "I transferred less data than
197 * you requested (maybe even zero bytes), nothing is wrong, except
198 * requested I/O hasn't completed". This will be returned back up to
199 * the application as a return from SSLRead(), SSLWrite(), SSLHandshake(),
203 (*SSLReadFunc
) (SSLConnectionRef connection
,
204 void *data
, /* owned by
207 size_t *dataLength
); /* IN/OUT */
209 (*SSLWriteFunc
) (SSLConnectionRef connection
,
211 size_t *dataLength
); /* IN/OUT */
213 /*************************************************
214 *** OSStatus values unique to SecureTransport ***
215 *************************************************/
218 Note: the comments that appear after these errors are used to create SecErrorMessages.strings.
219 The comments must not be multi-line, and should be in a form meaningful to an end user. If
220 a different or additional comment is needed, it can be put in the header doc format, or on a
221 line that does not start with errZZZ.
225 errSSLProtocol
= -9800, /* SSL protocol error */
226 errSSLNegotiation
= -9801, /* Cipher Suite negotiation failure */
227 errSSLFatalAlert
= -9802, /* Fatal alert */
228 errSSLWouldBlock
= -9803, /* I/O would block (not fatal) */
229 errSSLSessionNotFound
= -9804, /* attempt to restore an unknown session */
230 errSSLClosedGraceful
= -9805, /* connection closed gracefully */
231 errSSLClosedAbort
= -9806, /* connection closed via error */
232 errSSLXCertChainInvalid
= -9807, /* invalid certificate chain */
233 errSSLBadCert
= -9808, /* bad certificate format */
234 errSSLCrypto
= -9809, /* underlying cryptographic error */
235 errSSLInternal
= -9810, /* Internal error */
236 errSSLModuleAttach
= -9811, /* module attach failure */
237 errSSLUnknownRootCert
= -9812, /* valid cert chain, untrusted root */
238 errSSLNoRootCert
= -9813, /* cert chain not verified by root */
239 errSSLCertExpired
= -9814, /* chain had an expired cert */
240 errSSLCertNotYetValid
= -9815, /* chain had a cert not yet valid */
241 errSSLClosedNoNotify
= -9816, /* server closed session with no notification */
242 errSSLBufferOverflow
= -9817, /* insufficient buffer provided */
243 errSSLBadCipherSuite
= -9818, /* bad SSLCipherSuite */
245 /* fatal errors detected by peer */
246 errSSLPeerUnexpectedMsg
= -9819, /* unexpected message received */
247 errSSLPeerBadRecordMac
= -9820, /* bad MAC */
248 errSSLPeerDecryptionFail
= -9821, /* decryption failed */
249 errSSLPeerRecordOverflow
= -9822, /* record overflow */
250 errSSLPeerDecompressFail
= -9823, /* decompression failure */
251 errSSLPeerHandshakeFail
= -9824, /* handshake failure */
252 errSSLPeerBadCert
= -9825, /* misc. bad certificate */
253 errSSLPeerUnsupportedCert
= -9826, /* bad unsupported cert format */
254 errSSLPeerCertRevoked
= -9827, /* certificate revoked */
255 errSSLPeerCertExpired
= -9828, /* certificate expired */
256 errSSLPeerCertUnknown
= -9829, /* unknown certificate */
257 errSSLIllegalParam
= -9830, /* illegal parameter */
258 errSSLPeerUnknownCA
= -9831, /* unknown Cert Authority */
259 errSSLPeerAccessDenied
= -9832, /* access denied */
260 errSSLPeerDecodeError
= -9833, /* decoding error */
261 errSSLPeerDecryptError
= -9834, /* decryption error */
262 errSSLPeerExportRestriction
= -9835, /* export restriction */
263 errSSLPeerProtocolVersion
= -9836, /* bad protocol version */
264 errSSLPeerInsufficientSecurity
= -9837, /* insufficient security */
265 errSSLPeerInternalError
= -9838, /* internal error */
266 errSSLPeerUserCancelled
= -9839, /* user canceled */
267 errSSLPeerNoRenegotiation
= -9840, /* no renegotiation allowed */
269 /* non-fatal result codes */
270 errSSLPeerAuthCompleted
= -9841, /* peer cert is valid, or was ignored if verification disabled */
271 errSSLClientCertRequested
= -9842, /* server has requested a client cert */
273 /* more errors detected by us */
274 errSSLHostNameMismatch
= -9843, /* peer host name mismatch */
275 errSSLConnectionRefused
= -9844, /* peer dropped connection before responding */
276 errSSLDecryptionFail
= -9845, /* decryption failure */
277 errSSLBadRecordMac
= -9846, /* bad MAC */
278 errSSLRecordOverflow
= -9847, /* record overflow */
279 errSSLBadConfiguration
= -9848, /* configuration error */
280 errSSLUnexpectedRecord
= -9849, /* unexpected (skipped) record in DTLS */
281 errSSLWeakPeerEphemeralDHKey
= -9850, /* weak ephemeral dh key */
283 /* non-fatal result codes */
284 errSSLClientHelloReceived
= -9851, /* SNI */
287 /* DEPRECATED aliases for errSSLPeerAuthCompleted */
288 #define errSSLServerAuthCompleted errSSLPeerAuthCompleted
289 #define errSSLClientAuthCompleted errSSLPeerAuthCompleted
291 /* DEPRECATED alias for the end of the error range */
292 #define errSSLLast errSSLUnexpectedRecord
294 typedef CF_ENUM(int, SSLProtocolSide
)
300 typedef CF_ENUM(int, SSLConnectionType
)
312 * Secure Transport APIs require a SSLContextRef, which is an opaque
313 * reference to the SSL session and its parameters. On Mac OS X 10.7
314 * and earlier versions, a new context is created using SSLNewContext,
315 * and is disposed by calling SSLDisposeContext.
317 * On i0S 5.0 and later, as well as Mac OS X versions after 10.7, the
318 * SSLContextRef is a true CFType object with retain-release semantics.
319 * New code should create a new context using SSLCreateContext (instead
320 * of SSLNewContext), and dispose the context by calling CFRelease
321 * (instead of SSLDisposeContext) when finished with it.
325 * Return the CFTypeID for SSLContext objects.
328 SSLContextGetTypeID(void)
329 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
332 * Create a new instance of an SSLContextRef using the specified allocator.
336 SSLCreateContext(CFAllocatorRef __nullable alloc
, SSLProtocolSide protocolSide
, SSLConnectionType connectionType
)
337 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
340 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
342 * Create a new session context.
344 * ==========================
345 * MAC OS X ONLY (DEPRECATED)
346 * ==========================
347 * NOTE: this function is not available on iOS, and should be considered
348 * deprecated on Mac OS X. Your code should use SSLCreateContext instead.
351 SSLNewContext (Boolean isServer
,
352 SSLContextRef
* __nonnull CF_RETURNS_RETAINED contextPtr
) /* RETURNED */
353 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
356 * Dispose of a session context.
358 * ==========================
359 * MAC OS X ONLY (DEPRECATED)
360 * ==========================
361 * NOTE: this function is not available on iOS, and should be considered
362 * deprecated on Mac OS X. Your code should use CFRelease to dispose a session
363 * created with SSLCreateContext.
366 SSLDisposeContext (SSLContextRef context
)
367 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
369 #endif /* MAC OS X */
372 * Determine the state of an SSL/DTLS session.
375 SSLGetSessionState (SSLContextRef context
,
376 SSLSessionState
*state
) /* RETURNED */
377 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
380 * Set options for an SSL session. Must be called prior to SSLHandshake();
381 * subsequently cannot be called while session is active.
384 SSLSetSessionOption (SSLContextRef context
,
385 SSLSessionOption option
,
387 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
);
390 * Determine current value for the specified option in a given SSL session.
393 SSLGetSessionOption (SSLContextRef context
,
394 SSLSessionOption option
,
396 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
);
398 /********************************************************************
399 *** Session context configuration, common to client and servers. ***
400 ********************************************************************/
403 * Specify functions which do the network I/O. Must be called prior
404 * to SSLHandshake(); subsequently cannot be called while a session is
408 SSLSetIOFuncs (SSLContextRef context
,
409 SSLReadFunc readFunc
,
410 SSLWriteFunc writeFunc
)
411 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
414 * Set the minimum SSL protocol version allowed. Optional.
415 * The default is the lower supported protocol.
417 * This can only be called when no session is active.
419 * For TLS contexts, legal values for minVersion are :
425 * For DTLS contexts, legal values for minVersion are :
429 SSLSetProtocolVersionMin (SSLContextRef context
,
430 SSLProtocol minVersion
)
431 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
434 * Get minimum protocol version allowed
437 SSLGetProtocolVersionMin (SSLContextRef context
,
438 SSLProtocol
*minVersion
)
439 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
442 * Set the maximum SSL protocol version allowed. Optional.
443 * The default is the highest supported protocol.
445 * This can only be called when no session is active.
447 * For TLS contexts, legal values for minVersion are :
453 * For DTLS contexts, legal values for minVersion are :
457 SSLSetProtocolVersionMax (SSLContextRef context
,
458 SSLProtocol maxVersion
)
459 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
462 * Get maximum protocol version allowed
465 SSLGetProtocolVersionMax (SSLContextRef context
,
466 SSLProtocol
*maxVersion
)
467 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
470 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
472 * Set allowed SSL protocol versions. Optional.
473 * Specifying kSSLProtocolAll for SSLSetProtocolVersionEnabled results in
474 * specified 'enable' boolean to be applied to all supported protocols.
475 * The default is "all supported protocols are enabled".
476 * This can only be called when no session is active.
478 * Legal values for protocol are :
484 * ==========================
485 * MAC OS X ONLY (DEPRECATED)
486 * ==========================
487 * NOTE: this function is not available on iOS, and should be considered
488 * deprecated on Mac OS X. You can use SSLSetProtocolVersionMin and/or
489 * SSLSetProtocolVersionMax to specify which protocols are enabled.
492 SSLSetProtocolVersionEnabled (SSLContextRef context
,
493 SSLProtocol protocol
,
495 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
498 * Obtain a value specified in SSLSetProtocolVersionEnabled.
500 * ==========================
501 * MAC OS X ONLY (DEPRECATED)
502 * ==========================
503 * NOTE: this function is not available on iOS, and should be considered
504 * deprecated on Mac OS X. You can use SSLGetProtocolVersionMin and/or
505 * SSLGetProtocolVersionMax to check whether a protocol is enabled.
508 SSLGetProtocolVersionEnabled(SSLContextRef context
,
509 SSLProtocol protocol
,
510 Boolean
*enable
) /* RETURNED */
511 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
514 * Get/set SSL protocol version; optional. Default is kSSLProtocolUnknown,
515 * in which case the highest possible version is attempted, but a lower
516 * version is accepted if the peer requires it.
517 * SSLSetProtocolVersion cannot be called when a session is active.
519 * ==========================
520 * MAC OS X ONLY (DEPRECATED)
521 * ==========================
522 * NOTE: this function is not available on iOS, and deprecated on Mac OS X 10.8.
523 * Use SSLSetProtocolVersionMin and/or SSLSetProtocolVersionMax to specify
524 * which protocols are enabled.
527 SSLSetProtocolVersion (SSLContextRef context
,
529 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_8
,__IPHONE_NA
,__IPHONE_NA
);
532 * Obtain the protocol version specified in SSLSetProtocolVersion.
533 * If SSLSetProtocolVersionEnabled() has been called for this session,
534 * SSLGetProtocolVersion() may return errSecParam if the protocol enable
535 * state can not be represented by the SSLProtocol enums (e.g.,
536 * SSL2 and TLS1 enabled, SSL3 disabled).
538 * ==========================
539 * MAC OS X ONLY (DEPRECATED)
540 * ==========================
541 * NOTE: this function is not available on iOS, and deprecated on Mac OS X 10.8.
542 * Use SSLGetProtocolVersionMin and/or SSLGetProtocolVersionMax to check
543 * whether a protocol is enabled.
546 SSLGetProtocolVersion (SSLContextRef context
,
547 SSLProtocol
*protocol
) /* RETURNED */
548 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_8
,__IPHONE_NA
,__IPHONE_NA
);
550 #endif /* MAC OS X */
553 * Specify this connection's certificate(s). This is mandatory for
554 * server connections, optional for clients. Specifying a certificate
555 * for a client enables SSL client-side authentication. The end-entity
556 * cert is in certRefs[0]. Specifying a root cert is optional; if it's
557 * not specified, the root cert which verifies the cert chain specified
558 * here must be present in the system-wide set of trusted anchor certs.
560 * The certRefs argument is a CFArray containing SecCertificateRefs,
561 * except for certRefs[0], which is a SecIdentityRef.
563 * Must be called prior to SSLHandshake(), or immediately after
564 * SSLHandshake has returned errSSLClientCertRequested (i.e. before the
565 * handshake is resumed by calling SSLHandshake again.)
567 * SecureTransport assumes the following:
569 * -- The certRef references remain valid for the lifetime of the session.
570 * -- The certificate specified in certRefs[0] is capable of signing.
571 * -- The required capabilities of the certRef[0], and of the optional cert
572 * specified in SSLSetEncryptionCertificate (see below), are highly
573 * dependent on the application. For example, to work as a server with
574 * Netscape clients, the cert specified here must be capable of both
575 * signing and encrypting.
578 SSLSetCertificate (SSLContextRef context
,
580 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
583 * Specify I/O connection - a socket, endpoint, etc., which is
584 * managed by caller. On the client side, it's assumed that communication
585 * has been established with the desired server on this connection.
586 * On the server side, it's assumed that an incoming client request
587 * has been established.
589 * Must be called prior to SSLHandshake(); subsequently can only be
590 * called when no session is active.
593 SSLSetConnection (SSLContextRef context
,
594 SSLConnectionRef __nullable connection
)
595 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
598 SSLGetConnection (SSLContextRef context
,
599 SSLConnectionRef
* __nonnull CF_RETURNS_NOT_RETAINED connection
)
600 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
603 * Specify the fully qualified doman name of the peer, e.g., "store.apple.com."
604 * Optional; used to verify the common name field in peer's certificate.
605 * Name is in the form of a C string; NULL termination optional, i.e.,
606 * peerName[peerNameLen+1] may or may not have a NULL. In any case peerNameLen
607 * is the number of bytes of the peer domain name.
610 SSLSetPeerDomainName (SSLContextRef context
,
611 const char * __nullable peerName
,
613 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
616 * Determine the buffer size needed for SSLGetPeerDomainName().
619 SSLGetPeerDomainNameLength (SSLContextRef context
,
620 size_t *peerNameLen
) // RETURNED
621 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
624 * Obtain the value specified in SSLSetPeerDomainName().
627 SSLGetPeerDomainName (SSLContextRef context
,
628 char *peerName
, // returned here
629 size_t *peerNameLen
) // IN/OUT
630 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
633 * Specify the Datagram TLS Hello Cookie.
634 * This is to be called for server side only and is optional.
635 * The default is a zero len cookie. The maximum cookieLen is 32 bytes.
638 SSLSetDatagramHelloCookie (SSLContextRef dtlsContext
,
639 const void * __nullable cookie
,
641 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
644 * Specify the maximum record size, including all DTLS record headers.
645 * This should be set appropriately to avoid fragmentation
646 * of Datagrams during handshake, as fragmented datagrams may
647 * be dropped by some network.
648 * This is for Datagram TLS only
651 SSLSetMaxDatagramRecordSize (SSLContextRef dtlsContext
,
653 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
656 * Get the maximum record size, including all Datagram TLS record headers.
657 * This is for Datagram TLS only
660 SSLGetMaxDatagramRecordSize (SSLContextRef dtlsContext
,
662 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
665 * Obtain the actual negotiated protocol version of the active
666 * session, which may be different that the value specified in
667 * SSLSetProtocolVersion(). Returns kSSLProtocolUnknown if no
668 * SSL session is in progress.
671 SSLGetNegotiatedProtocolVersion (SSLContextRef context
,
672 SSLProtocol
*protocol
) /* RETURNED */
673 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
676 * Determine number and values of all of the SSLCipherSuites we support.
677 * Caller allocates output buffer for SSLGetSupportedCiphers() and passes in
678 * its size in *numCiphers. If supplied buffer is too small, errSSLBufferOverflow
682 SSLGetNumberSupportedCiphers (SSLContextRef context
,
684 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
687 SSLGetSupportedCiphers (SSLContextRef context
,
688 SSLCipherSuite
*ciphers
, /* RETURNED */
689 size_t *numCiphers
) /* IN/OUT */
690 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
693 * Specify a (typically) restricted set of SSLCipherSuites to be enabled by
694 * the current SSLContext. Can only be called when no session is active. Default
695 * set of enabled SSLCipherSuites is the same as the complete set of supported
696 * SSLCipherSuites as obtained by SSLGetSupportedCiphers().
699 SSLSetEnabledCiphers (SSLContextRef context
,
700 const SSLCipherSuite
*ciphers
,
702 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
705 * Determine number and values of all of the SSLCipherSuites currently enabled.
706 * Caller allocates output buffer for SSLGetEnabledCiphers() and passes in
707 * its size in *numCiphers. If supplied buffer is too small, errSSLBufferOverflow
711 SSLGetNumberEnabledCiphers (SSLContextRef context
,
713 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
716 SSLGetEnabledCiphers (SSLContextRef context
,
717 SSLCipherSuite
*ciphers
, /* RETURNED */
718 size_t *numCiphers
) /* IN/OUT */
719 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
722 /* Deprecated, does nothing */
723 typedef CF_ENUM(int, SSLSessionStrengthPolicy
)
725 kSSLSessionStrengthPolicyDefault
,
726 kSSLSessionStrengthPolicyATSv1
,
727 kSSLSessionStrengthPolicyATSv1_noPFS
,
731 SSLSetSessionStrengthPolicy(SSLContextRef context
,
732 SSLSessionStrengthPolicy policyStrength
);
735 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
737 * Enable/disable peer certificate chain validation. Default is enabled.
738 * If caller disables, it is the caller's responsibility to call
739 * SSLCopyPeerCertificates() upon successful completion of the handshake
740 * and then to perform external validation of the peer certificate
741 * chain before proceeding with data transfer.
743 * ==========================
744 * MAC OS X ONLY (DEPRECATED)
745 * ==========================
746 * NOTE: this function is not available on iOS, and should be considered
747 * deprecated on Mac OS X. To disable peer certificate chain validation, you
748 * can instead use SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth
749 * to true. This will disable verification and cause SSLHandshake to return with
750 * an errSSLServerAuthCompleted result when the peer certificates have been
751 * received; at that time, you can choose to evaluate peer trust yourself, or
752 * simply call SSLHandshake again to proceed with the handshake.
755 SSLSetEnableCertVerify (SSLContextRef context
,
756 Boolean enableVerify
)
757 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
760 * Check whether peer certificate chain validation is enabled.
762 * ==========================
763 * MAC OS X ONLY (DEPRECATED)
764 * ==========================
765 * NOTE: this function is not available on iOS, and should be considered
766 * deprecated on Mac OS X. To check whether peer certificate chain validation
767 * is enabled in a context, call SSLGetSessionOption to obtain the value of
768 * the kSSLSessionOptionBreakOnServerAuth session option flag. If the value
769 * of this option flag is true, then verification is disabled.
772 SSLGetEnableCertVerify (SSLContextRef context
,
773 Boolean
*enableVerify
) /* RETURNED */
774 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
777 * Specify the option of ignoring certificates' "expired" times.
778 * This is a common failure in the real SSL world. Default setting for this
779 * flag is false, meaning expired certs result in an errSSLCertExpired error.
781 * ==========================
782 * MAC OS X ONLY (DEPRECATED)
783 * ==========================
784 * NOTE: this function is not available on iOS, and should be considered
785 * deprecated on Mac OS X. To ignore expired certificate errors, first disable
786 * Secure Transport's automatic verification of peer certificates by calling
787 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
788 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
789 * your code should obtain the SecTrustRef for the peer's certificates and
790 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
791 * The SecTrustSetOptions function allows you to specify that the expiration
792 * status of certificates should be ignored for this evaluation.
796 * status = SSLSetSessionOption(ctx, kSSLSessionOptionBreakOnServerAuth, true);
798 * status = SSLHandshake(ctx);
800 * if (status == errSSLServerAuthCompleted) {
801 * SecTrustRef peerTrust = NULL;
802 * status = SSLCopyPeerTrust(ctx, &peerTrust);
803 * if (status == errSecSuccess) {
804 * SecTrustResultType trustResult;
805 * // set flag to allow expired certificates
806 * SecTrustSetOptions(peerTrust, kSecTrustOptionAllowExpired);
807 * status = SecTrustEvaluate(peerTrust, &trustResult);
808 * if (status == errSecSuccess) {
809 * // A "proceed" result means the cert is explicitly trusted,
810 * // e.g. "Always Trust" was clicked;
811 * // "Unspecified" means the cert has no explicit trust settings,
812 * // but is implicitly OK since it chains back to a trusted root.
813 * // Any other result means the cert is not trusted.
815 * if (trustResult == kSecTrustResultProceed ||
816 * trustResult == kSecTrustResultUnspecified) {
817 * // certificate is trusted
818 * status = errSSLWouldBlock; // so we call SSLHandshake again
819 * } else if (trustResult == kSecTrustResultRecoverableTrustFailure) {
820 * // not trusted, for some reason other than being expired;
821 * // could ask the user whether to allow the connection here
823 * status = errSSLXCertChainInvalid;
825 * // cannot use this certificate (fatal)
826 * status = errSSLBadCert;
830 * CFRelease(peerTrust);
833 * } // errSSLServerAuthCompleted
835 * } while (status == errSSLWouldBlock);
839 SSLSetAllowsExpiredCerts (SSLContextRef context
,
840 Boolean allowsExpired
)
841 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
844 * Obtain the current value of an SSLContext's "allowExpiredCerts" flag.
846 * ==========================
847 * MAC OS X ONLY (DEPRECATED)
848 * ==========================
849 * NOTE: this function is not available on iOS, and should be considered
850 * deprecated on Mac OS X.
853 SSLGetAllowsExpiredCerts (SSLContextRef context
,
854 Boolean
*allowsExpired
) /* RETURNED */
855 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
858 * Similar to SSLSetAllowsExpiredCerts, SSLSetAllowsExpiredRoots allows the
859 * option of ignoring "expired" status for root certificates only.
860 * Default setting is false, i.e., expired root certs result in an
861 * errSSLCertExpired error.
863 * ==========================
864 * MAC OS X ONLY (DEPRECATED)
865 * ==========================
866 * NOTE: this function is not available on iOS, and should be considered
867 * deprecated on Mac OS X. To ignore expired certificate errors, first disable
868 * Secure Transport's automatic verification of peer certificates by calling
869 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
870 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
871 * your code should obtain the SecTrustRef for the peer's certificates and
872 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
873 * The SecTrustSetOptions function allows you to specify that the expiration
874 * status of certificates should be ignored for this evaluation.
876 * See the description of the SSLSetAllowsExpiredCerts function (above)
877 * for a code example. The kSecTrustOptionAllowExpiredRoot option can be used
878 * instead of kSecTrustOptionAllowExpired to allow expired roots only.
881 SSLSetAllowsExpiredRoots (SSLContextRef context
,
882 Boolean allowsExpired
)
883 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
886 * Obtain the current value of an SSLContext's "allow expired roots" flag.
888 * ==========================
889 * MAC OS X ONLY (DEPRECATED)
890 * ==========================
891 * NOTE: this function is not available on iOS, and should be considered
892 * deprecated on Mac OS X.
895 SSLGetAllowsExpiredRoots (SSLContextRef context
,
896 Boolean
*allowsExpired
) /* RETURNED */
897 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
900 * Specify option of allowing for an unknown root cert, i.e., one which
901 * this software can not verify as one of a list of known good root certs.
902 * Default for this flag is false, in which case one of the following two
904 * -- The peer returns a cert chain with a root cert, and the chain
905 * verifies to that root, but the root is not one of our trusted
906 * roots. This results in errSSLUnknownRootCert on handshake.
907 * -- The peer returns a cert chain which does not contain a root cert,
908 * and we can't verify the chain to one of our trusted roots. This
909 * results in errSSLNoRootCert on handshake.
911 * Both of these error conditions are ignored when the AllowAnyRoot flag is
912 * true, allowing connection to a totally untrusted peer.
914 * ==========================
915 * MAC OS X ONLY (DEPRECATED)
916 * ==========================
917 * NOTE: this function is not available on iOS, and should be considered
918 * deprecated on Mac OS X. To ignore unknown root cert errors, first disable
919 * Secure Transport's automatic verification of peer certificates by calling
920 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
921 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
922 * your code should obtain the SecTrustRef for the peer's certificates and
923 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
925 * See the description of the SSLSetAllowsExpiredCerts function (above)
926 * for a code example. Note that an unknown root certificate will cause
927 * SecTrustEvaluate to report kSecTrustResultRecoverableTrustFailure as the
931 SSLSetAllowsAnyRoot (SSLContextRef context
,
933 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
936 * Obtain the current value of an SSLContext's "allow any root" flag.
938 * ==========================
939 * MAC OS X ONLY (DEPRECATED)
940 * ==========================
941 * NOTE: this function is not available on iOS, and should be considered
942 * deprecated on Mac OS X.
945 SSLGetAllowsAnyRoot (SSLContextRef context
,
946 Boolean
*anyRoot
) /* RETURNED */
947 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
950 * Augment or replace the system's default trusted root certificate set
951 * for this session. If replaceExisting is true, the specified roots will
952 * be the only roots which are trusted during this session. If replaceExisting
953 * is false, the specified roots will be added to the current set of trusted
954 * root certs. If this function has never been called, the current trusted
955 * root set is the same as the system's default trusted root set.
956 * Successive calls with replaceExisting false result in accumulation
957 * of additional root certs.
959 * The trustedRoots array contains SecCertificateRefs.
961 * ==========================
962 * MAC OS X ONLY (DEPRECATED)
963 * ==========================
964 * NOTE: this function is not available on iOS, and should be considered
965 * deprecated on Mac OS X. To trust specific roots in a session, first disable
966 * Secure Transport's automatic verification of peer certificates by calling
967 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true. When
968 * SSLHandshake subsequently returns an errSSLServerAuthCompleted result,
969 * your code should obtain the SecTrustRef for the peer's certificates and
970 * perform a custom trust evaluation with SecTrust APIs (see SecTrust.h).
972 * See the description of the SSLSetAllowsExpiredCerts function (above)
973 * for a code example. You can call SecTrustSetAnchorCertificates to
974 * augment the system's trusted root set, or SecTrustSetAnchorCertificatesOnly
975 * to make these the only trusted roots, prior to calling SecTrustEvaluate.
978 SSLSetTrustedRoots (SSLContextRef context
,
979 CFArrayRef trustedRoots
,
980 Boolean replaceExisting
)
981 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
984 * Obtain an array of SecCertificateRefs representing the current
985 * set of trusted roots. If SSLSetTrustedRoots() has never been called
986 * for this session, this returns the system's default root set.
988 * Caller must CFRelease the returned CFArray.
990 * ==========================
991 * MAC OS X ONLY (DEPRECATED)
992 * ==========================
993 * NOTE: this function is not available on iOS, and should be considered
994 * deprecated on Mac OS X. To get the current set of trusted roots, call the
995 * SSLCopyPeerTrust function to obtain the SecTrustRef for the peer certificate
996 * chain, then SecTrustCopyCustomAnchorCertificates (see SecTrust.h).
999 SSLCopyTrustedRoots (SSLContextRef context
,
1000 CFArrayRef
* __nonnull CF_RETURNS_RETAINED trustedRoots
) /* RETURNED */
1001 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1004 * Request peer certificates. Valid anytime, subsequent to a handshake attempt.
1006 * The certs argument is a CFArray containing SecCertificateRefs.
1007 * Caller must CFRelease the returned array.
1009 * The cert at index 0 of the returned array is the subject (end
1010 * entity) cert; the root cert (or the closest cert to it) is at
1011 * the end of the returned array.
1013 * ==========================
1014 * MAC OS X ONLY (DEPRECATED)
1015 * ==========================
1016 * NOTE: this function is not available on iOS, and should be considered
1017 * deprecated on Mac OS X. To get peer certificates, call SSLCopyPeerTrust
1018 * to obtain the SecTrustRef for the peer certificate chain, then use the
1019 * SecTrustGetCertificateCount and SecTrustGetCertificateAtIndex functions
1020 * to retrieve individual certificates in the chain (see SecTrust.h).
1023 SSLCopyPeerCertificates (SSLContextRef context
,
1024 CFArrayRef
* __nonnull CF_RETURNS_RETAINED certs
) /* RETURNED */
1025 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1027 #endif /* MAC OS X */
1030 * Obtain a SecTrustRef representing peer certificates. Valid anytime,
1031 * subsequent to a handshake attempt. Caller must CFRelease the returned
1034 * The returned trust reference will have already been evaluated for you,
1035 * unless one of the following is true:
1036 * - Your code has disabled automatic certificate verification, by calling
1037 * SSLSetSessionOption to set kSSLSessionOptionBreakOnServerAuth to true.
1038 * - Your code has called SSLSetPeerID, and this session has been resumed
1039 * from an earlier cached session.
1041 * In these cases, your code should call SecTrustEvaluate prior to
1042 * examining the peer certificate chain or trust results (see SecTrust.h).
1044 * NOTE: if you have not called SSLHandshake at least once prior to
1045 * calling this function, the returned trust reference will be NULL.
1048 SSLCopyPeerTrust (SSLContextRef context
,
1049 SecTrustRef
* __nonnull CF_RETURNS_RETAINED trust
) /* RETURNED */
1050 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
);
1053 * Specify some data, opaque to this library, which is sufficient
1054 * to uniquely identify the peer of the current session. An example
1055 * would be IP address and port, stored in some caller-private manner.
1056 * To be optionally called prior to SSLHandshake for the current
1057 * session. This is mandatory if this session is to be resumable.
1059 * SecureTransport allocates its own copy of the incoming peerID. The
1060 * data provided in *peerID, while opaque to SecureTransport, is used
1061 * in a byte-for-byte compare to other previous peerID values set by the
1062 * current application. Matching peerID blobs result in SecureTransport
1063 * attempting to resume an SSL session with the same parameters as used
1064 * in the previous session which specified the same peerID bytes.
1067 SSLSetPeerID (SSLContextRef context
,
1068 const void * __nullable peerID
,
1070 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1073 * Obtain current PeerID. Returns NULL pointer, zero length if
1074 * SSLSetPeerID has not been called for this context.
1077 SSLGetPeerID (SSLContextRef context
,
1078 const void * __nullable
* __nonnull peerID
,
1080 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1083 * Obtain the SSLCipherSuite (e.g., SSL_RSA_WITH_DES_CBC_SHA) negotiated
1084 * for this session. Only valid when a session is active.
1087 SSLGetNegotiatedCipher (SSLContextRef context
,
1088 SSLCipherSuite
*cipherSuite
)
1089 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1092 /********************************************************
1093 *** Session context configuration, server side only. ***
1094 ********************************************************/
1097 * This function is deprecated in OSX 10.11 and iOS 9.0 and
1098 * has no effect on the TLS handshake since OSX 10.10 and
1099 * iOS 8.0. Using separate RSA certificates for encryption
1100 * and signing is no longer supported.
1103 SSLSetEncryptionCertificate (SSLContextRef context
,
1104 CFArrayRef certRefs
)
1105 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
, __MAC_10_11
, __IPHONE_5_0
, __IPHONE_9_0
);
1108 * Specify requirements for client-side authentication.
1109 * Optional; Default is kNeverAuthenticate.
1111 * Can only be called when no session is active.
1113 typedef CF_ENUM(int, SSLAuthenticate
) {
1114 kNeverAuthenticate
, /* skip client authentication */
1115 kAlwaysAuthenticate
, /* require it */
1116 kTryAuthenticate
/* try to authenticate, but not an error
1117 * if client doesn't have a cert */
1121 SSLSetClientSideAuthenticate (SSLContextRef context
,
1122 SSLAuthenticate auth
)
1123 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1126 * Add a DER-encoded distinguished name to list of acceptable names
1127 * to be specified in requests for client certificates.
1130 SSLAddDistinguishedName (SSLContextRef context
,
1131 const void * __nullable derDN
,
1133 __OSX_AVAILABLE_STARTING(__MAC_10_4
, __IPHONE_5_0
);
1136 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
1138 * Add a SecCertificateRef, or a CFArray of them, to a server's list
1139 * of acceptable Certificate Authorities (CAs) to present to the client
1140 * when client authentication is performed.
1142 * If replaceExisting is true, the specified certificate(s) will replace
1143 * a possible existing list of acceptable CAs. If replaceExisting is
1144 * false, the specified certificate(s) will be appended to the existing
1145 * list of acceptable CAs, if any.
1147 * Returns errSecParam if this is called on a SSLContextRef which
1148 * is configured as a client, or when a session is active.
1150 * NOTE: this function is currently not available on iOS.
1153 SSLSetCertificateAuthorities(SSLContextRef context
,
1154 CFTypeRef certificateOrArray
,
1155 Boolean replaceExisting
)
1156 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
);
1159 * Obtain the certificates specified in SSLSetCertificateAuthorities(),
1160 * if any. Returns a NULL array if SSLSetCertificateAuthorities() has not
1162 * Caller must CFRelease the returned array.
1164 * NOTE: this function is currently not available on iOS.
1167 SSLCopyCertificateAuthorities(SSLContextRef context
,
1168 CFArrayRef
* __nonnull CF_RETURNS_RETAINED certificates
) /* RETURNED */
1169 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
);
1171 #endif /* MAC OS X */
1174 * Obtain the list of acceptable distinguished names as provided by
1175 * a server (if the SSLContextRef is configured as a client), or as
1176 * specified by SSLSetCertificateAuthorities (if the SSLContextRef
1177 * is configured as a server).
1178 * The returned array contains CFDataRefs, each of which represents
1179 * one DER-encoded RDN.
1181 * Caller must CFRelease the returned array.
1184 SSLCopyDistinguishedNames (SSLContextRef context
,
1185 CFArrayRef
* __nonnull CF_RETURNS_RETAINED names
)
1186 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_5_0
);
1189 * Obtain client certificate exchange status. Can be called
1190 * any time. Reflects the *last* client certificate state change;
1191 * subsequent to a renegotiation attempt by either peer, the state
1192 * is reset to kSSLClientCertNone.
1195 SSLGetClientCertificateState (SSLContextRef context
,
1196 SSLClientCertificateState
*clientState
)
1197 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_5_0
);
1200 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
1202 * Specify Diffie-Hellman parameters. Optional; if we are configured to allow
1203 * for D-H ciphers and a D-H cipher is negotiated, and this function has not
1204 * been called, a set of process-wide parameters will be calculated. However
1205 * that can take a long time (30 seconds).
1207 * NOTE: this function is currently not available on iOS.
1209 OSStatus
SSLSetDiffieHellmanParams (SSLContextRef context
,
1210 const void * __nullable dhParams
,
1212 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_NA
);
1215 * Return parameter block specified in SSLSetDiffieHellmanParams.
1216 * Returned data is not copied and belongs to the SSLContextRef.
1218 * NOTE: this function is currently not available on iOS.
1220 OSStatus
SSLGetDiffieHellmanParams (SSLContextRef context
,
1221 const void * __nullable
* __nonnull dhParams
,
1222 size_t *dhParamsLen
)
1223 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_NA
);
1226 * Enable/Disable RSA blinding. This feature thwarts a known timing
1227 * attack to which RSA keys are vulnerable; enabling it is a tradeoff
1228 * between performance and security. The default for RSA blinding is
1231 * ==========================
1232 * MAC OS X ONLY (DEPRECATED)
1233 * ==========================
1234 * NOTE: this function is not available on iOS, and should be considered
1235 * deprecated on Mac OS X. RSA blinding is enabled unconditionally, as
1236 * it prevents a known way for an attacker to recover the private key,
1237 * and the performance gain of disabling it is negligible.
1239 OSStatus
SSLSetRsaBlinding (SSLContextRef context
,
1241 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1243 OSStatus
SSLGetRsaBlinding (SSLContextRef context
,
1245 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2
,__MAC_10_9
,__IPHONE_NA
,__IPHONE_NA
);
1247 #endif /* MAC OS X */
1249 /*******************************
1250 ******** I/O Functions ********
1251 *******************************/
1254 * Note: depending on the configuration of the underlying I/O
1255 * connection, all SSL I/O functions can return errSSLWouldBlock,
1256 * indicating "not complete, nothing is wrong, except required
1257 * I/O hasn't completed". Caller may need to repeat I/Os as necessary
1258 * if the underlying connection has been configured to behave in
1259 * a non-blocking manner.
1263 * Perform the SSL handshake. On successful return, session is
1264 * ready for normal secure application I/O via SSLWrite and SSLRead.
1266 * Interesting error returns:
1268 * errSSLUnknownRootCert: Peer had a valid cert chain, but the root of
1269 * the chain is unknown.
1271 * errSSLNoRootCert: Peer had a cert chain which did not end in a root.
1273 * errSSLCertExpired: Peer's cert chain had one or more expired certs.
1275 * errSSLXCertChainInvalid: Peer had an invalid cert chain (i.e.,
1276 * signature verification within the chain failed, or no certs
1279 * In all of the above errors, the handshake was aborted; the peer's
1280 * cert chain is available via SSLCopyPeerTrust or SSLCopyPeerCertificates.
1282 * Other interesting result codes:
1284 * errSSLPeerAuthCompleted: Peer's cert chain is valid, or was ignored if
1285 * cert verification was disabled via SSLSetEnableCertVerify. The application
1286 * may decide to continue with the handshake (by calling SSLHandshake
1287 * again), or close the connection at this point.
1289 * errSSLClientCertRequested: The server has requested a client certificate.
1290 * The client may choose to examine the server's certificate and
1291 * distinguished name list, then optionally call SSLSetCertificate prior
1292 * to resuming the handshake by calling SSLHandshake again.
1294 * A return value of errSSLWouldBlock indicates that SSLHandshake has to be
1295 * called again (and again and again until something else is returned).
1298 SSLHandshake (SSLContextRef context
)
1299 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1302 * Normal application-level read/write. On both of these, a errSSLWouldBlock
1303 * return and a partially completed transfer - or even zero bytes transferred -
1304 * are NOT mutually exclusive.
1307 SSLWrite (SSLContextRef context
,
1308 const void * __nullable data
,
1310 size_t *processed
) /* RETURNED */
1311 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1314 * data is mallocd by caller; available size specified in
1315 * dataLength; actual number of bytes read returned in
1319 SSLRead (SSLContextRef context
,
1320 void * data
, /* RETURNED */
1322 size_t *processed
) /* RETURNED */
1323 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1326 * Determine how much data the client can be guaranteed to
1327 * obtain via SSLRead() without blocking or causing any low-level
1328 * read operations to occur.
1331 SSLGetBufferedReadSize (SSLContextRef context
,
1332 size_t *bufSize
) /* RETURNED */
1333 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1336 * Determine how much data the application can be guaranteed to write
1337 * with SSLWrite() without causing fragmentation. The value is based on
1338 * the maximum Datagram Record size defined by the application with
1339 * SSLSetMaxDatagramRecordSize(), minus the DTLS Record header size.
1342 SSLGetDatagramWriteSize (SSLContextRef dtlsContext
,
1344 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_5_0
);
1347 * Terminate current SSL session.
1350 SSLClose (SSLContextRef context
)
1351 __OSX_AVAILABLE_STARTING(__MAC_10_2
, __IPHONE_5_0
);
1353 CF_IMPLICIT_BRIDGING_DISABLED
1354 CF_ASSUME_NONNULL_END
1360 #endif /* !_SECURITY_SECURETRANSPORT_H_ */