From b0bcf506aa0dfac1b7cdced99c55117e245b93ba Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 2 Jun 2018 16:02:52 -0400 Subject: [PATCH] Can now disable the update hash check --- .../com/rarchives/ripme/ui/UpdateUtils.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index ebfa1428..9b78a7c8 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -229,17 +229,20 @@ public class UpdateUtils { try (FileOutputStream out = new FileOutputStream(updateFileName)) { out.write(response.bodyAsBytes()); } - String updateHash = createSha256(new File(updateFileName)); - logger.info("Download of new version complete; saved to " + updateFileName); - logger.info("Checking hash of update"); + // Only check the hash if the user hasn't disabled hash checking + if (Utils.getConfigBoolean("security.check_update_hash", true)) { + String updateHash = createSha256(new File(updateFileName)); + logger.info("Download of new version complete; saved to " + updateFileName); + logger.info("Checking hash of update"); - if (!ripmeJson.getString("currentHash").equals(updateHash)) { - logger.error("Error: Update has bad hash"); - logger.debug("Expected hash: " + ripmeJson.getString("currentHash")); - logger.debug("Actual hash: " + updateHash); - throw new IOException("Got bad file hash"); - } else { - logger.info("Hash is good"); + if (!ripmeJson.getString("currentHash").equals(updateHash)) { + logger.error("Error: Update has bad hash"); + logger.debug("Expected hash: " + ripmeJson.getString("currentHash")); + logger.debug("Actual hash: " + updateHash); + throw new IOException("Got bad file hash"); + } else { + logger.info("Hash is good"); + } } if (shouldLaunch) { // Setup updater script