Can now disable the update hash check

This commit is contained in:
cyian-1756 2018-06-02 16:02:52 -04:00
parent 10d256a6e5
commit b0bcf506aa

View File

@ -229,17 +229,20 @@ public class UpdateUtils {
try (FileOutputStream out = new FileOutputStream(updateFileName)) { try (FileOutputStream out = new FileOutputStream(updateFileName)) {
out.write(response.bodyAsBytes()); out.write(response.bodyAsBytes());
} }
String updateHash = createSha256(new File(updateFileName)); // Only check the hash if the user hasn't disabled hash checking
logger.info("Download of new version complete; saved to " + updateFileName); if (Utils.getConfigBoolean("security.check_update_hash", true)) {
logger.info("Checking hash of update"); 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)) { if (!ripmeJson.getString("currentHash").equals(updateHash)) {
logger.error("Error: Update has bad hash"); logger.error("Error: Update has bad hash");
logger.debug("Expected hash: " + ripmeJson.getString("currentHash")); logger.debug("Expected hash: " + ripmeJson.getString("currentHash"));
logger.debug("Actual hash: " + updateHash); logger.debug("Actual hash: " + updateHash);
throw new IOException("Got bad file hash"); throw new IOException("Got bad file hash");
} else { } else {
logger.info("Hash is good"); logger.info("Hash is good");
}
} }
if (shouldLaunch) { if (shouldLaunch) {
// Setup updater script // Setup updater script