Minor refactoring / renaming / copy edits

This commit is contained in:
Mattt Thompson 2013-04-17 18:28:08 +02:00
parent 8ea42866b8
commit 174bc47c84
2 changed files with 9 additions and 9 deletions

View file

@ -128,9 +128,11 @@ NSCoding, NSCopying>
@property (readonly, nonatomic, strong) NSError *error; @property (readonly, nonatomic, strong) NSError *error;
/** /**
The flag to determine if the connection should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. Whether the connection should accept an invalid SSL certificate.
If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`.
*/ */
@property (nonatomic,assign) BOOL allowInvalidSSLCertificate; @property (nonatomic, assign) BOOL allowInvalidSSLCertificate;
///---------------------------- ///----------------------------
/// @name Getting Response Data /// @name Getting Response Data

View file

@ -258,7 +258,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
self.state = AFOperationReadyState; self.state = AFOperationReadyState;
//This ifdef has been added for backwards compatibility purposes // #ifdef included for backwards-compatibility
#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
self.allowInvalidSSLCertificate = YES; self.allowInvalidSSLCertificate = YES;
#endif #endif
@ -611,11 +611,10 @@ willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challe
break; break;
} }
case AFSSLPinningModeNone: { case AFSSLPinningModeNone: {
if(self.allowInvalidSSLCertificate == YES){ if (self.allowInvalidSSLCertificate){
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
} } else {
else {
SecTrustResultType result = 0; SecTrustResultType result = 0;
OSStatus status = SecTrustEvaluate(serverTrust, &result); OSStatus status = SecTrustEvaluate(serverTrust, &result);
NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
@ -656,13 +655,12 @@ canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{ {
if(self.allowInvalidSSLCertificate == YES if (self.allowInvalidSSLCertificate
&& [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
return; return;
} }
if (self.authenticationChallenge) { if (self.authenticationChallenge) {
self.authenticationChallenge(connection, challenge); self.authenticationChallenge(connection, challenge);
} else { } else {