public void ReplaceMobileProvision(byte[] mobileProvisionBytes) { m_zipFile.BeginUpdate(); MemoryStreamDataSource mobileProvisionDataSource = new MemoryStreamDataSource(mobileProvisionBytes); m_zipFile.Add(mobileProvisionDataSource, m_appDirectoryPath + MobileProvisionFileName); CodeResourcesFile codeResources = GetCodeResourcesFile(); codeResources.UpdateFileHash(MobileProvisionFileName, mobileProvisionBytes); MobileProvisionFile mobileProvision = new MobileProvisionFile(mobileProvisionBytes); string provisionedBundleIdentifier = mobileProvision.PList.Entitlements.BundleIdentifier; if (provisionedBundleIdentifier != GetBundleIdentifier()) { // We must update the info.plist's CFBundleIdentifier to match the one from the mobile provision InfoFile infoFile = GetInfoFile(); infoFile.BundleIdentifier = provisionedBundleIdentifier; byte[] infoBytes = infoFile.GetBytes(); MemoryStreamDataSource infoDataSource = new MemoryStreamDataSource(infoBytes); m_zipFile.Add(infoDataSource, m_appDirectoryPath + InfoFileName); codeResources.UpdateFileHash(InfoFileName, infoBytes); } byte[] codeResourcesBytes = codeResources.GetBytes(); MemoryStreamDataSource codeResourcesDataSource = new MemoryStreamDataSource(codeResourcesBytes); m_zipFile.Add(codeResourcesDataSource, m_appDirectoryPath + CodeResourcesFilePath); m_zipFile.CommitUpdate(); }
public void ResignIPA(List <X509Certificate> certificateChain, AsymmetricKeyEntry privateKey) { MobileProvisionFile mobileProvision = GetMobileProvision(); byte[] buffer = GetExecutableBytes(); string bundleIdentifier = GetBundleIdentifier(); byte[] infoFileBytes = GetInfoFileBytes(); byte[] codeResourcesBytes = GetCodeResourcesBytes(); List <MachObjectFile> files = MachObjectHelper.ReadMachObjects(buffer); foreach (MachObjectFile file in files) { CodeSignatureHelper.ResignExecutable(file, bundleIdentifier, certificateChain, privateKey, infoFileBytes, codeResourcesBytes, mobileProvision.PList.Entitlements); } byte[] executableBytes = MachObjectHelper.PackMachObjects(files); ReplaceExecutable(executableBytes); }