From 213b03ea56146ad1568b5d9eab26d337d5d6a551 Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 16 Jun 2023 08:13:05 +0800 Subject: [PATCH] Print warning message when signature key is missing (#2283) --- HMCL/build.gradle.kts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/HMCL/build.gradle.kts b/HMCL/build.gradle.kts index ae2a844ae..66e599299 100644 --- a/HMCL/build.gradle.kts +++ b/HMCL/build.gradle.kts @@ -56,7 +56,12 @@ fun createChecksum(file: 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 signer = Signature.getInstance("SHA512withRSA") signer.initSign(privatekey)