アプリは相互認証を使用してサーバーに接続するため、証明書を含む .p12 ファイルがあります。すべてが想定どおりに機能しますが、Instruments を使用してアプリをプロファイリングしているときに、次の行でメモリ リークが検出されます。
if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodClientCertificate]){
NSData* p12data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"client" ofType:@"p12"]];
CFArrayRef itemsCFArray = nil;
NSDictionary* dico = [NSDictionary dictionaryWithObjectsAndKeys:@"password",kSecImportExportPassphrase, nil];
// MEMORY LEAK just below
OSStatus check = SecPKCS12Import((__bridge CFDataRef)p12data, (__bridge CFDictionaryRef)dico, &itemsCFArray);
if(check != noErr){
NSLog(@"Error importing PKCS");
}
NSArray* items = (__bridge NSArray*)itemsCFArray;
SecIdentityRef identityRef = (__bridge SecIdentityRef)[[items objectAtIndex:0] objectForKey:(__bridge id)kSecImportItemIdentity];
NSURLCredential* credential = [NSURLCredential credentialWithIdentity:identityRef certificates:nil persistence:NSURLCredentialPersistenceNone];
[challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
}
代わりに CFDictionaryRef を使用しようとしましたが、エラーは解決しません。
同じ問題を抱えている人を見つけましたが、彼の解決策はios4で、私はios5を使用しています(実際、私はすでに同じことをしています): http://www.ipup.fr/forum/viewtopic.php?id =2855 (フランス語で申し訳ありません)
どうすればこれを解決できますか? Apple は、このメモリ リークのために私のアプリを拒否しますか?