Skip to content

Commit 121a295

Browse files
committed
Improving documentation for startTLS
1 parent 94ef39e commit 121a295

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

GCD/GCDAsyncSocket.h

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,43 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
631631
* are finished. This allows one the option of sending a protocol dependent StartTLS message, and queuing
632632
* the upgrade to TLS at the same time, without having to wait for the write to finish.
633633
* Any reads or writes scheduled after this method is called will occur over the secured connection.
634-
*
635-
* The available keys are:
634+
*
635+
* ==== The available TOP-LEVEL KEYS are:
636+
*
637+
* - GCDAsyncSocketManuallyEvaluateTrust
638+
* The value must be of type NSNumber, encapsulating a BOOL value.
639+
* If you set this to YES, then the underlying SecureTransport system will not evaluate the SecTrustRef of the peer.
640+
* Instead it will pause at the moment evaulation would typically occur,
641+
* and allow us to handle the security evaluation however we see fit.
642+
* So GCDAsyncSocket will invoke the delegate method socket:shouldTrustPeer: passing the SecTrustRef.
643+
*
644+
* Note that if you set this option, then all other configuration keys are ignored.
645+
* Evaluation will be completely up to you during the socket:shouldTrustPeer: delegate method.
646+
*
647+
* For more information on trust evaluation see:
648+
* Apple's Technical Note TN2232 - HTTPS Server Trust Evaluation
649+
* https://developer.apple.com/library/ios/technotes/tn2232/_index.html
650+
*
651+
* If unspecified, the default value is NO.
652+
*
653+
* - GCDAsyncSocketUseCFStreamForTLS (iOS only)
654+
* The value must be of type NSNumber, encapsulating a BOOL value.
655+
* By default GCDAsyncSocket will use the SecureTransport layer to perform encryption.
656+
* This gives us more control over the security protocol (many more configuration options),
657+
* plus it allows us to optimize things like sys calls and buffer allocation.
658+
*
659+
* However, if you absolutely must, you can instruct GCDAsyncSocket to use the old-fashioned encryption
660+
* technique by going through the CFStream instead. So instead of using SecureTransport, GCDAsyncSocket
661+
* will instead setup a CFRead/CFWriteStream. And then set the kCFStreamPropertySSLSettings property
662+
* (via CFReadStreamSetProperty / CFWriteStreamSetProperty) and will pass the given options to this method.
663+
*
664+
* Thus all the other keys in the given dictionary will be ignored by GCDAsyncSocket,
665+
* and will passed directly CFReadStreamSetProperty / CFWriteStreamSetProperty.
666+
* For more infomation on these keys, please see the documentation for kCFStreamPropertySSLSettings.
667+
*
668+
* If unspecified, the default value is NO.
669+
*
670+
* ==== The available CONFIGURATION KEYS are:
636671
*
637672
* - kCFStreamSSLPeerName
638673
* The value must be of type NSString.
@@ -661,35 +696,36 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
661696
* See the documentation for SSLSetProtocolVersionMin & SSLSetProtocolVersionMax.
662697
* See also the SSLProtocol typedef.
663698
*
664-
* - GCDAsyncSocketSSLDiffieHellmanParameters () [Mac OS X only]
699+
* - GCDAsyncSocketSSLDiffieHellmanParameters (Mac OS X only)
665700
*
666-
* The following keys are NOT available (and with throw an exception):
701+
* ==== The following UNAVAILABLE KEYS are: (with throw an exception)
667702
*
668703
* - kCFStreamSSLAllowsAnyRoot (UNAVAILABLE)
669-
* You MUST use manualTrustEvaluation.
704+
* You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust).
670705
* Corresponding deprecated method: SSLSetAllowsAnyRoot
671706
*
672707
* - kCFStreamSSLAllowsExpiredRoots (UNAVAILABLE)
673-
* You MUST use manualTrustEvaluation.
708+
* You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust).
674709
* Corresponding deprecated method: SSLSetAllowsExpiredRoots
675710
*
676711
* - kCFStreamSSLAllowsExpiredCertificates (UNAVAILABLE)
677-
* You MUST use manualTrustEvaluation.
712+
* You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust).
678713
* Corresponding deprecated method: SSLSetAllowsExpiredCerts
679714
*
680715
* - kCFStreamSSLValidatesCertificateChain (UNAVAILABLE)
681-
* You MUST use manualTrustEvaluation.
716+
* You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust).
682717
* Corresponding deprecated method: SSLSetEnableCertVerify
683718
*
684719
* - kCFStreamSSLLevel (UNAVAILABLE)
685-
* You MUST use GCDAsyncSocketSSLProtocolVersionMin / Max instead.
720+
* You MUST use GCDAsyncSocketSSLProtocolVersionMin & GCDAsyncSocketSSLProtocolVersionMin instead.
686721
* Corresponding deprecated method: SSLSetProtocolVersionEnabled
687722
*
688723
*
689724
* Please refer to Apple's documentation for corresponding SSLFunctions.
690-
*
725+
*
691726
* If you pass in nil or an empty dictionary, the default settings will be used.
692727
*
728+
* IMPORTANT SECURITY NOTE:
693729
* The default settings will check to make sure the remote party's certificate is signed by a
694730
* trusted 3rd party certificate agency (e.g. verisign) and that the certificate is not expired.
695731
* However it will not verify the name on the certificate unless you
@@ -702,7 +738,7 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
702738
* To properly secure your connection in this particular scenario you
703739
* should set the kCFStreamSSLPeerName property to "MySecureServer.com".
704740
*
705-
* You can also perform additional validation via the certificate provided in socketDidSecure.
741+
* You can also perform additional validation in socketDidSecure.
706742
**/
707743
- (void)startTLS:(NSDictionary *)tlsSettings;
708744

0 commit comments

Comments
 (0)