我有以下代码来检索私钥
-(SecKeyRef)getKey:(NSData *)pkcs12Data
{
SecKeyRef privateKeyRef = nil;
if(pkcs12Data ==nil || pkcs12Data.length==0)
{
return privateKeyRef;
}
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: @"", kSecImportExportPassphrase, nil];
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL);
// this line gives the warning <Error>: Nov xxxxxxx SecTrustEvaluate [leaf AnchorTrusted]
OSStatus returnCode = SecPKCS12Import(
(__bridge CFDataRef) pkcs12Data,
(__bridge CFDictionaryRef) options,
& items
);
if(errSecSuccess == returnCode)
{
NSDictionary *item = (NSDictionary*) CFArrayGetValueAtIndex(items, 0);
SecIdentityRef identity = (__bridge SecIdentityRef) [item objectForKey:(__bridge NSString *) kSecImportItemIdentity];
SecIdentityCopyPrivateKey(identity, &privateKeyRef);
}
else
{
NSLog(@"failed “);
}
return privateKeyRef;
}
其中pkcs12Data是.pfx文件的数据。 虽然一切正常但我在设备日志中的SecTrustEvaluate [leaf AnchorTrusted]中收到警告。我没有任何理由这样做。请让我知道如何摆脱这个警告。