Skip to content

Commit

Permalink
Retain identityRef retrieved from file
Browse files Browse the repository at this point in the history
Currently the identity has a chance to be released before it's added to an NSURLCredential.
  • Loading branch information
russellhancox authored Apr 26, 2017
1 parent 8ead0aa commit 08e4331
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Source/MOLAuthenticatingURLSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,11 @@ - (SecIdentityRef)identityFromFile:(NSString *)file password:(NSString *)passwor
[self log:@"Client Trust: Couldn't load client certificate %@: %d", self.clientCertFile, err];
return nil;
}

CFDictionaryRef firstDict = [identities firstObject];
SecIdentityRef firstRef = (__bridge SecIdentityRef)firstDict[(__bridge id)kSecImportItemIdentity];

return (__bridge SecIdentityRef)[identities firstObject][(__bridge id)kSecImportItemIdentity];
return (firstRef != NULL) ? CFRetain(firstRef) : NULL;
}

- (void)log:(NSString *)format, ... {
Expand Down

0 comments on commit 08e4331

Please sign in to comment.