diff --git a/Source/MOLAuthenticatingURLSession.m b/Source/MOLAuthenticatingURLSession.m index 39cb173..45352cb 100644 --- a/Source/MOLAuthenticatingURLSession.m +++ b/Source/MOLAuthenticatingURLSession.m @@ -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, ... {