Skip to content

Commit

Permalink
fix: move the keystore to the output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jun 14, 2022
1 parent 6c6abaf commit 6ceb449
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/kotlin/app/revanced/cli/signing/Signing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ object Signing {
// 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)
val keyStore = Signer(cn, password).signApk(alignedOutput, signedOutput)

// afterwards copy over the file to the output
// afterwards copy over the file and the keystore to the output
signedOutput.copyTo(outputFile, true)
keyStore.copyTo(outputFile.resolveSibling(keyStore.name), true)
}
}
7 changes: 5 additions & 2 deletions src/main/kotlin/app/revanced/utils/signing/Signer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ internal class Signer(
return JcaX509CertificateConverter().getCertificate(builder.build(signer)) to pair.private
}

fun signApk(input: File, output: File) {
fun signApk(input: File, output: File): File {
Security.addProvider(BouncyCastleProvider())

val ks = File(input.parent, "revanced-cli.keystore")
// TODO: keystore should be saved securely
val ks = File(input.parent, "${output.nameWithoutExtension}.keystore")
if (!ks.exists()) newKeystore(ks)

val keyStore = KeyStore.getInstance("BKS", "BC")
Expand All @@ -70,5 +71,7 @@ internal class Signer(
signer.setOutputApk(output)

signer.build().sign()

return ks
}
}

0 comments on commit 6ceb449

Please sign in to comment.