From 22d2535af8b3ea8fa58b6beb2938d240afa0a17d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 11 Jun 2022 19:56:45 +0200 Subject: [PATCH] fix: sign the aligned file instead of the input file --- src/main/kotlin/app/revanced/cli/signing/Signing.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/app/revanced/cli/signing/Signing.kt b/src/main/kotlin/app/revanced/cli/signing/Signing.kt index f314c082..f6c9e244 100644 --- a/src/main/kotlin/app/revanced/cli/signing/Signing.kt +++ b/src/main/kotlin/app/revanced/cli/signing/Signing.kt @@ -7,17 +7,18 @@ import java.io.File object Signing { fun start(inputFile: File, outputFile: File, cn: String, password: String) { - // align & sign val cacheDirectory = File(cacheDirectory) val alignedOutput = cacheDirectory.resolve("aligned.apk") val signedOutput = cacheDirectory.resolve("signed.apk") + + // align the inputFile and write to alignedOutput ZipAligner.align(inputFile, alignedOutput) - Signer( - cn, - password - ).signApk(inputFile, signedOutput) + // sign the alignedOutput and write to signedOutput + // the reason is, in case the signer fails + // it does not damage the output file + Signer(cn, password).signApk(alignedOutput, signedOutput) - // write to output + // afterwards copy over the file to the output signedOutput.copyTo(outputFile) } }