Print warning message when signature key is missing (#2283)

This commit is contained in:
Glavo 2023-06-16 08:13:05 +08:00 committed by GitHub
parent 959c4d0698
commit 213b03ea56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,12 @@ fun createChecksum(file: File) {
} }
fun attachSignature(jar: File) { fun attachSignature(jar: File) {
val keyLocation = System.getenv("HMCL_SIGNATURE_KEY") ?: return val keyLocation = System.getenv("HMCL_SIGNATURE_KEY")
if (keyLocation == null) {
logger.warn("Missing signature key")
return
}
val privatekey = KeyFactory.getInstance("RSA").generatePrivate(PKCS8EncodedKeySpec(File(keyLocation).readBytes())) val privatekey = KeyFactory.getInstance("RSA").generatePrivate(PKCS8EncodedKeySpec(File(keyLocation).readBytes()))
val signer = Signature.getInstance("SHA512withRSA") val signer = Signature.getInstance("SHA512withRSA")
signer.initSign(privatekey) signer.initSign(privatekey)