10
10
11
11
#import < Foundation/Foundation.h>
12
12
#import < Security/Security.h>
13
+ #import < Security/SecureTransport.h>
13
14
#import < dispatch/dispatch.h>
14
15
15
16
@class GCDAsyncReadPacket;
16
17
@class GCDAsyncWritePacket;
17
18
19
+ #if TARGET_OS_IPHONE
20
+
21
+ // Compiling for iOS
22
+
23
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // iOS 5.0 supported
24
+
25
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000 // iOS 5.0 supported and required
26
+
27
+ #define IS_SECURE_TRANSPORT_AVAILABLE YES
28
+ #define SECURE_TRANSPORT_MAYBE_AVAILABLE 1
29
+ #define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 0
30
+
31
+ #else // iOS 5.0 supported but not required
32
+
33
+ #ifndef NSFoundationVersionNumber_iPhoneOS_5_0
34
+ #define NSFoundationVersionNumber_iPhoneOS_5_0 881.00
35
+ #endif
36
+
37
+ #define IS_SECURE_TRANSPORT_AVAILABLE (NSFoundationVersionNumber >= NSFoundationVersionNumber_iPhoneOS_5_0)
38
+ #define SECURE_TRANSPORT_MAYBE_AVAILABLE 1
39
+ #define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 1
40
+
41
+ #endif
42
+
43
+ #else // iOS 5.0 not supported
44
+
45
+ #define IS_SECURE_TRANSPORT_AVAILABLE NO
46
+ #define SECURE_TRANSPORT_MAYBE_AVAILABLE 0
47
+ #define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 1
48
+
49
+ #endif
50
+
51
+ #else
52
+
53
+ // Compiling for Mac OS X
54
+
55
+ #define IS_SECURE_TRANSPORT_AVAILABLE YES
56
+ #define SECURE_TRANSPORT_MAYBE_AVAILABLE 1
57
+ #define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 0
58
+
59
+ #endif
60
+
18
61
extern NSString *const GCDAsyncSocketException;
19
62
extern NSString *const GCDAsyncSocketErrorDomain;
20
63
21
64
extern NSString *const GCDAsyncSocketQueueName;
22
65
extern NSString *const GCDAsyncSocketThreadName;
23
66
24
- #if !TARGET_OS_IPHONE
67
+ #if SECURE_TRANSPORT_MAYBE_AVAILABLE
25
68
extern NSString *const GCDAsyncSocketSSLCipherSuites;
69
+ #if TARGET_OS_IPHONE
70
+ extern NSString *const GCDAsyncSocketSSLProtocolVersionMin;
71
+ extern NSString *const GCDAsyncSocketSSLProtocolVersionMax;
72
+ #else
26
73
extern NSString *const GCDAsyncSocketSSLDiffieHellmanParameters;
27
74
#endif
75
+ #endif
28
76
29
77
enum GCDAsyncSocketError
30
78
{
@@ -82,7 +130,8 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
82
130
CFStreamClientContext streamContext;
83
131
CFReadStreamRef readStream;
84
132
CFWriteStreamRef writeStream;
85
- #else
133
+ #endif
134
+ #if SECURE_TRANSPORT_MAYBE_AVAILABLE
86
135
SSLContextRef sslContext;
87
136
NSMutableData *sslReadBuffer;
88
137
size_t sslWriteCachedLength;
@@ -681,7 +730,8 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
681
730
* Any reads or writes scheduled after this method is called will occur over the secured connection.
682
731
*
683
732
* The possible keys and values for the TLS settings are well documented.
684
- * Some possible keys are:
733
+ * Standard keys are:
734
+ *
685
735
* - kCFStreamSSLLevel
686
736
* - kCFStreamSSLAllowsExpiredCertificates
687
737
* - kCFStreamSSLAllowsExpiredRoots
@@ -691,6 +741,18 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
691
741
* - kCFStreamSSLCertificates
692
742
* - kCFStreamSSLIsServer
693
743
*
744
+ * If SecureTransport is available on iOS:
745
+ *
746
+ * - GCDAsyncSocketSSLCipherSuites
747
+ * - GCDAsyncSocketSSLProtocolVersionMin
748
+ * - GCDAsyncSocketSSLProtocolVersionMax
749
+ *
750
+ * If SecureTransport is available on Mac OS X:
751
+ *
752
+ * - GCDAsyncSocketSSLCipherSuites
753
+ * - GCDAsyncSocketSSLDiffieHellmanParameters;
754
+ *
755
+ *
694
756
* Please refer to Apple's documentation for associated values, as well as other possible keys.
695
757
*
696
758
* If you pass in nil or an empty dictionary, the default settings will be used.
0 commit comments