From 14a11c8a1a8063eb90c31e50d7daa2769293cd71 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 5 Nov 2017 10:05:03 +0100 Subject: [PATCH] Add jar signing, fixes #1514 --- CHANGELOG.md | 1 + build.gradle | 15 +++++++++++++++ .../java/com/raoulvdberge/refinedstorage/RS.java | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a755dc784..1f366c356 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - The Crafter can now only store 1 stack size pattern per slot (raoulvdberge) - You can now re-insert a Pattern in the pattern output slot in the Pattern Grid to modify an existing pattern (raoulvdberge) - Fixed not being able to use JEI R and U keys on Grid with tabs (raoulvdberge) +- The Refined Storage jar is now signed (raoulvdberge) ### 1.5.21 - Updated Portuguese (Brazilian) translation (Pinz714) diff --git a/build.gradle b/build.gradle index e35b7994b..5b5cc88d8 100755 --- a/build.gradle +++ b/build.gradle @@ -96,6 +96,21 @@ task apiJar(type: Jar, dependsOn: 'sourceMainJava') { classifier 'api' } +task signJar(type: SignJar, dependsOn: reobfJar) { + onlyIf { + project.hasProperty('keyStore') + } + + keyStore = project.findProperty('keyStore') + alias = project.findProperty('keyStoreAlias') + storePass = project.findProperty('keyStorePass') + keyPass = project.findProperty('keyStoreKeyPass') + inputFile = jar.archivePath + outputFile = jar.archivePath +} + +build.dependsOn signJar + artifacts { archives deobfJar archives apiJar diff --git a/src/main/java/com/raoulvdberge/refinedstorage/RS.java b/src/main/java/com/raoulvdberge/refinedstorage/RS.java index f8ac4c2f9..78bf1e3de 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/RS.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/RS.java @@ -4,17 +4,19 @@ import com.raoulvdberge.refinedstorage.proxy.ProxyCommon; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; -@Mod(modid = RS.ID, version = RS.VERSION, dependencies = RS.DEPENDENCIES, acceptedMinecraftVersions = "[1.12,1.13)", guiFactory = RS.GUI_FACTORY, updateJSON = RS.UPDATE_JSON) +@Mod(modid = RS.ID, version = RS.VERSION, dependencies = RS.DEPENDENCIES, acceptedMinecraftVersions = "[1.12,1.13)", guiFactory = RS.GUI_FACTORY, updateJSON = RS.UPDATE_JSON, certificateFingerprint = RS.FINGERPRINT) public final class RS { static { FluidRegistry.enableUniversalBucket(); @@ -25,6 +27,7 @@ public final class RS { public static final String DEPENDENCIES = "required-after:forge@[14.21.0.2363,);after:mcmultipart@[2.2.1,);after:storagedrawers@[1.12-5.2.2,);"; public static final String GUI_FACTORY = "com.raoulvdberge.refinedstorage.gui.config.ModGuiFactory"; public static final String UPDATE_JSON = "https://refinedstorage.raoulvdberge.com/update"; + public static final String FINGERPRINT = "57893d5b90a7336e8c63fe1c1e1ce472c3d59578"; @SidedProxy(clientSide = "com.raoulvdberge.refinedstorage.proxy.ProxyClient", serverSide = "com.raoulvdberge.refinedstorage.proxy.ProxyCommon") public static ProxyCommon PROXY; @@ -57,4 +60,9 @@ public final class RS { public void postInit(FMLPostInitializationEvent e) { PROXY.postInit(e); } + + @EventHandler + public void onFingerprintViolation(FMLFingerprintViolationEvent e) { + FMLLog.bigWarning("Invalid fingerprint detected for the Refined Storage jar file! The file " + e.getSource().getName() + " may have been tampered with. This version will NOT be supported!"); + } }