|
81 | 81 | NSString *const GCDAsyncSocketException = @"GCDAsyncSocketException";
|
82 | 82 | NSString *const GCDAsyncSocketErrorDomain = @"GCDAsyncSocketErrorDomain";
|
83 | 83 |
|
| 84 | +#if !TARGET_OS_IPHONE |
| 85 | +NSString *const GCDAsyncSocketSSLCipherSuites = @"GCDAsyncSocketSSLCipherSuites"; |
| 86 | +NSString *const GCDAsyncSocketSSLDiffieHellmanParameters = @"GCDAsyncSocketSSLDiffieHellmanParameters"; |
| 87 | +#endif |
| 88 | + |
84 | 89 | enum GCDAsyncSocketFlags
|
85 | 90 | {
|
86 | 91 | kDidStartDelegate = 1 << 0, // If set, disconnection results in delegate call
|
@@ -4818,6 +4823,8 @@ - (void)maybeStartTLS
|
4818 | 4823 | // 5. kCFStreamSSLAllowsExpiredCertificates
|
4819 | 4824 | // 6. kCFStreamSSLCertificates
|
4820 | 4825 | // 7. kCFStreamSSLLevel
|
| 4826 | + // 8. GCDAsyncSocketSSLCipherSuites |
| 4827 | + // 9. GCDAsyncSocketSSLDiffieHellmanParameters |
4821 | 4828 |
|
4822 | 4829 | id value;
|
4823 | 4830 |
|
@@ -4960,6 +4967,44 @@ - (void)maybeStartTLS
|
4960 | 4967 | }
|
4961 | 4968 | }
|
4962 | 4969 |
|
| 4970 | + // 8. GCDAsyncSocketSSLCipherSuites |
| 4971 | + |
| 4972 | + value = [tlsSettings objectForKey:GCDAsyncSocketSSLCipherSuites]; |
| 4973 | + if (value) |
| 4974 | + { |
| 4975 | + NSArray *cipherSuites = (NSArray *)value; |
| 4976 | + NSUInteger numberCiphers = [cipherSuites count]; |
| 4977 | + SSLCipherSuite ciphers[numberCiphers]; |
| 4978 | + |
| 4979 | + for (NSUInteger cipherIndex = 0; cipherIndex < numberCiphers; cipherIndex++) |
| 4980 | + { |
| 4981 | + NSNumber *cipherObject = [cipherSuites objectAtIndex:cipherIndex]; |
| 4982 | + ciphers[cipherIndex] = [cipherObject shortValue]; |
| 4983 | + } |
| 4984 | + |
| 4985 | + status = SSLSetEnabledCiphers(sslContext, ciphers, numberCiphers); |
| 4986 | + if (status != noErr) |
| 4987 | + { |
| 4988 | + [self closeWithError:[self otherError:@"Error in SSLSetEnabledCiphers"]]; |
| 4989 | + return; |
| 4990 | + } |
| 4991 | + } |
| 4992 | + |
| 4993 | + // 9. GCDAsyncSocketSSLDiffieHellmanParameters |
| 4994 | + |
| 4995 | + value = [tlsSettings objectForKey:GCDAsyncSocketSSLDiffieHellmanParameters]; |
| 4996 | + if (value) |
| 4997 | + { |
| 4998 | + NSData *diffieHellmanData = (NSData *)value; |
| 4999 | + |
| 5000 | + status = SSLSetDiffieHellmanParams(sslContext, [diffieHellmanData bytes], [diffieHellmanData length]); |
| 5001 | + if (status != noErr) |
| 5002 | + { |
| 5003 | + [self closeWithError:[self otherError:@"Error in SSLSetDiffieHellmanParams"]]; |
| 5004 | + return; |
| 5005 | + } |
| 5006 | + } |
| 5007 | + |
4963 | 5008 | // Setup the sslReadBuffer
|
4964 | 5009 | //
|
4965 | 5010 | // If there is any data in the partialReadBuffer,
|
|
0 commit comments