fix: move the keystore to the output directory

This commit is contained in:
oSumAtrIX 2022-06-14 23:52:40 +02:00
parent 6c6abafe95
commit 6ceb449cf8
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 8 additions and 4 deletions

View File

@ -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)
}
}

View File

@ -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")
@ -70,5 +71,7 @@ internal class Signer(
signer.setOutputApk(output)
signer.build().sign()
return ks
}
}