我正在尝试使用 OSX 上的 Core Foundation 库使其工作。
但是,我看到许可证验证确实不一致,有时它验证得很好,有时则没有,使用完全相同的文件。
这是我目前正在使用的代码:
- (void)checkApexProcess{
CFMutableStringRef key = CFStringCreateMutable(NULL, 0);
CFStringAppend(key, CFSTR("0xB57B7D0E180"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("C4FD9AAAFC389F8"));
CFStringAppend(key, CFSTR("438903BC20D0"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("E"));
CFStringAppend(key, CFSTR("1F02C25010F8F47C"));
CFStringAppend(key, CFSTR("86"));
CFStringAppend(key, CFSTR("C"));
CFStringAppend(key, CFSTR("C"));
CFStringAppend(key, CFSTR("4FABF44A4376945C6F8F92292B"));
CFStringAppend(key, CFSTR("D45043012F6959BD6D3E1D246D1C1B"));
CFStringAppend(key, CFSTR("6F4A53FA1C023B4A91BC4578504B1D"));
CFStringAppend(key, CFSTR("9BEA69A53FAE91FD36ACA165CA57"));
CFStringAppend(key, CFSTR("B"));
CFStringAppend(key, CFSTR("B"));
CFStringAppend(key, CFSTR(""));
CFStringAppend(key, CFSTR("B"));
CFStringAppend(key, CFSTR("4"));
CFStringAppend(key, CFSTR("4"));
CFStringAppend(key, CFSTR("C30A925FAFBB1CA595D5011DA0E"));
CFStringAppend(key, CFSTR("BF819BC6A909861DE8C5121FCA06AF"));
CFStringAppend(key, CFSTR("FB3290875E3ED23D1F"));
APSetKey(key);
NSURL* filePath;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
CFURLRef filePathUrl;
bool Valid;
//CFDictionaryRef cfUserLicenseInfo;
NSDictionary* apexDict;
if ( [openDlg runModal] == NSOKButton )
{
for( NSURL* URL in [openDlg URLs] )
{
filePath = URL;
NSString* filePathString = [URL path];
filePathUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef) filePathString, kCFURLPOSIXPathStyle, FALSE);
//CFDictionaryRef cfUserLicenseInfo = APCreateDictionaryForLicenseFile(filePathUrl);
Valid = APVerifyLicenseFile(filePathUrl);
//Valid = APVerifyLicenseData(cfUserLicenseInfo);
DDLogCVerbose( @"%@", filePath );
DDLogCVerbose( @"%@", filePathUrl );
DDLogCVerbose( @"%@", [URL path] );
//apexDict = [NSDictionary dictionaryWithContentsOfFile:(filePathString)];
}
//Valid = testValidLicenseFile2(filePathUrl);
if(Valid == true){
//[self storeLicenseFile:filePath];
[self enableApexButtons];
} else {
[self displayApexAlertInvalid];
[self removeApexFile];
}
}
}
我真的对这里发生的事情感到困惑,我真的不明白它有时如何验证,而不是其他人?
有人有什么想法吗?
谢谢
加雷斯
编辑 1
奇怪的是,如果我注释掉这些行:
CFDictionaryRef cfUserLicenseInfo;
NSDictionary* apexDict;
然后验证通过,如果没有则失败,这非常奇怪,有人有什么想法吗?