bdrister/AquaticPrime

Inconsistent license validation

Closed this issue · 1 comments

I am trying to get this to work using the Core Foundation library on OSX.

However i am seeing really inconsistent license validation, sometimes it validates fine, then other times not, using exactly the same file.

Here is the code i am using at the moment:

   - (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];
}
}

  }

These issues are almost certainly bugs in your code unrelated to the AP framework itself. For instance, your "valid" bool is uninitialized, so if you cancel out of the dialog, it'll randomly consider it licensed or not. There's nothing nondeterministic in the way the framework works, so you shouldn't see any differing behaviors on its end.