Ejemplo n.º 1
0
        private void btnTestIPA_Click(object sender, EventArgs e)
        {
            string     inputIPAPath           = txtInputIPA.Text;
            string     signingCertificatePath = txtSigningCertificate.Text;
            string     certificatePassword    = txtCertificatePassword.Text;
            FileStream ipaStream;

            byte[] signingCertificateBytes;

            try
            {
                ipaStream = new FileStream(inputIPAPath, FileMode.Open, FileAccess.Read);
            }
            catch (IOException)
            {
                MessageBox.Show("Failed to read Input IPA file", "Error");
                return;
            }

            try
            {
                signingCertificateBytes = File.ReadAllBytes(signingCertificatePath);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Failed to read signing certificate file", "Error");
                return;
            }
            catch (IOException)
            {
                MessageBox.Show("Failed to read signing certificate file", "Error");
                return;
            }

            IPAFile ipaFile = new IPAFile(ipaStream);
            var     msg     = ipaFile.ValidateIPA(signingCertificateBytes, certificatePassword);

            if (msg == "Success")
            {
                MessageBox.Show("Signature is valid", "Success");
            }
            else
            {
                MessageBox.Show(msg, "Error");
            }
        }