Permalink
Browse files

Minor refactoring and reformatting

  • Loading branch information...
1 parent 07c9f6c commit 46559bd6ca11dc343da9d155355a92de96ec00ad @mattt mattt committed Dec 26, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 AFNetworking/AFURLConnectionOperation.m
@@ -175,9 +175,9 @@ + (NSThread *)networkRequestThread {
+ (NSArray *)pinnedCertificates {
static NSArray *_pinnedCertificates = nil;
- static dispatch_once_t oncePredicate;
+ static dispatch_once_t onceToken;
- dispatch_once(&oncePredicate, ^{
+ dispatch_once(&onceToken, ^{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
NSMutableArray *certificates = [NSMutableArray array];
@@ -486,15 +486,15 @@ - (void)cancelConnection {
#pragma mark - NSURLConnectionDelegate
#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_
--(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
+- (void)connection:(NSURLConnection *)connection
+willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0);
- NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate));
-
- NSArray *pinnedCertificates = [[self class] pinnedCertificates];
- if ([pinnedCertificates containsObject:remoteCertificateData]) {
+ NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate);
+
+ if ([[[self class] pinnedCertificates] containsObject:certificateData]) {
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
} else {

0 comments on commit 46559bd

Please sign in to comment.