示例#1
0
        /**
         * Using the stub IPA previously compiled on the Mac, create a new IPA with assets
         */
        void ResignIPA(FileOperations.FileSystemAdapter FileSystem)
        {
            try
            {
                DateTime StartTime = DateTime.Now;

                // Configure the custom code signer
                CustomCodeSigner SigningContext = new CustomCodeSigner();
                SigningContext.FileSystem = FileSystem;

                // Custom mobile provision?
                if (RBSpecifyMobileProvision.Checked)
                {
                    SigningContext.CustomMobileProvision = File.ReadAllBytes(MobileProvisionEdit.Text);
                }

                // Custom cert?
                if (RBUseExplicitCert.Checked)
                {
                    string CertificatePassword = "";
                    try
                    {
                        SigningContext.CustomSigningCert = new X509Certificate2(CertificateEdit.Text, CertificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);
                        //Cert = new X509Certificate2(CertificateFilename, CertificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);
                    }
                    catch (System.Security.Cryptography.CryptographicException ex)
                    {
                        // Try once with a password
                        if (PasswordDialog.RequestPassword(out CertificatePassword))
                        {
                            SigningContext.CustomSigningCert = new X509Certificate2(CertificateEdit.Text, CertificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);
                            //Cert = new X509Certificate2(CertificateFilename, CertificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);
                        }
                        else
                        {
                            // User cancelled dialog, rethrow
                            throw ex;
                        }
                    }
                }

                // Totally replace Info.plist? (just editing it is handled later)
                if (RBReplaceInfoPList.Checked)
                {
                    SigningContext.CustomInfoPList = ImportedPListData;
                }

                // Start the resign process
                SigningContext.PrepareForSigning();

                // Partially modify Info.plist?
                if (RBModifyInfoPList.Checked)
                {
                    SigningContext.Info.SetString("CFBundleDisplayName", DisplayNameEdit.Text);
                    SigningContext.Info.SetString("CFBundleIdentifier", BundleIDEdit.Text);
                }

                // Re-sign the executable
                SigningContext.PerformSigning();

                // Save the IPA
                Program.Log("Saving IPA ...");
                FileSystem.Close();

                TimeSpan ElapsedTime = DateTime.Now - StartTime;
                Program.Log(String.Format("Finished re-signing IPA in took {0:0.00} s", ElapsedTime.TotalSeconds));

                MessageBox.Show("Re-signing succeeded!", Config.AppDisplayName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                ShowError("re-signing IPA", ex);
            }
        }