美文网首页
iOS 防止二次打包 笔记

iOS 防止二次打包 笔记

作者: 豪冷 | 来源:发表于2019-07-26 10:05 被阅读0次

检测embedded.mobileprovision是否被篡改:

// 校验值,可通过上一次打包获取
#define PROVISION_HASH @"Mfx1YZk7hZShm/IyV1QLWdogSQM="
static NSDictionary *rootDic=nil;

void checkSignatureMsg()
{
    NSString *newPath = [[NSBundle mainBundle] resourcePath];

    if (!rootDic) {
        rootDic = [[NSDictionary alloc] initWithContentsOfFile:[newPath stringByAppendingString:@"/_CodeSignature/CodeResources"]];
    }

    NSDictionary *fileDic = [rootDic objectForKey:@"files2"];
    NSDictionary *infoDic = [fileDic objectForKey:@"embedded.mobileprovision"];
    NSData *tempData = [infoDic objectForKey:@"hash"];
    NSString *hashStr = [tempData base64EncodedStringWithOptions:0];
    if (![PROVISION_HASH isEqualToString:hashStr]) {
        abort();//退出应用
    }
}

相关文章

网友评论

      本文标题:iOS 防止二次打包 笔记

      本文链接:https://www.haomeiwen.com/subject/wixrrctx.html