DiscordSRV

DiscordSRV

86.8k Downloads

java.security.InvalidKeyException: Illegal key size

jascotty2 opened this issue ยท 3 comments

commented

Attempting to run /discord debug on the newest version (1.16.8) as it seems to no longer work in 1.16.7, and I get this error:

> discord debug
[06:00:13 WARN]: java.security.InvalidKeyException: Illegal key size
[06:00:13 WARN]:        at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
[06:00:13 WARN]:        at javax.crypto.Cipher.init(Cipher.java:1393)
[06:00:13 WARN]:        at javax.crypto.Cipher.init(Cipher.java:1327)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.encrypt(DebugUtil.java:320)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.encrypt(DebugUtil.java:306)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.uploadToBin(DebugUtil.java:257)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.uploadReport(DebugUtil.java:238)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.run(DebugUtil.java:106)
[06:00:13 WARN]:        at github.scarsz.discordsrv.commands.CommandDebug.execute(CommandDebug.java:33)
[06:00:13 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[06:00:13 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[06:00:13 WARN]:        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[06:00:13 WARN]:        at java.lang.reflect.Method.invoke(Method.java:498)
[06:00:13 WARN]:        at github.scarsz.discordsrv.objects.managers.CommandManager.handle(CommandManager.java:97)
[06:00:13 WARN]:        at github.scarsz.discordsrv.DiscordSRV.onCommand(DiscordSRV.java:533)
[06:00:13 WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
[06:00:13 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:151)
[06:00:13 WARN]:        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:734)
[06:00:13 WARN]:        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchServerCommand(CraftServer.java:696)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.DedicatedServer.handleCommandQueue(DedicatedServer.java:483)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:440)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:940)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:837)
[06:00:13 WARN]:        at java.lang.Thread.run(Thread.java:748)
[06:00:13 WARN]: java.lang.NullPointerException
[06:00:13 WARN]:        at java.util.Base64$Encoder.encode(Base64.java:261)
[06:00:13 WARN]:        at java.util.Base64$Encoder.encodeToString(Base64.java:315)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.b64(DebugUtil.java:296)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.uploadToBin(DebugUtil.java:257)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.uploadReport(DebugUtil.java:238)
[06:00:13 WARN]:        at github.scarsz.discordsrv.util.DebugUtil.run(DebugUtil.java:106)
[06:00:13 WARN]:        at github.scarsz.discordsrv.commands.CommandDebug.execute(CommandDebug.java:33)
[06:00:13 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[06:00:13 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[06:00:13 WARN]:        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[06:00:13 WARN]:        at java.lang.reflect.Method.invoke(Method.java:498)
[06:00:13 WARN]:        at github.scarsz.discordsrv.objects.managers.CommandManager.handle(CommandManager.java:97)
[06:00:13 WARN]:        at github.scarsz.discordsrv.DiscordSRV.onCommand(DiscordSRV.java:533)
[06:00:13 WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
[06:00:13 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:151)
[06:00:13 WARN]:        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:734)
[06:00:13 WARN]:        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchServerCommand(CraftServer.java:696)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.DedicatedServer.handleCommandQueue(DedicatedServer.java:483)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:440)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:940)
[06:00:13 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:837)
[06:00:13 WARN]:        at java.lang.Thread.run(Thread.java:748)
[06:00:13 INFO]: Your debug report has been generated and is available at ERROR/Failed to send debug report: null.

commented

I added some code to save to a directory, so I got the information I needed from the debug (don't like restarting the server if I don't have to)

		File dir = new File(DiscordSRV.getPlugin().getDataFolder(), "debug-" + System.currentTimeMillis());
		dir.mkdir();
		try {
			for (Map<String, String> file : files) {
				File f = new File(dir, file.get("name"));
				FileWriter fstream = new FileWriter(f);
				BufferedWriter out = new BufferedWriter(fstream);
				out.write(file.get("content"));
				out.close();
				fstream.close();
			}
		} catch (Throwable t) {
			DiscordSRV.getPlugin().getLogger().log(Level.SEVERE, "Failed to save debug information: ", t);
		}

If you need me to test, I can try it sometime tomorrow morning when it's not busy. I use a custom build that synchronizes nicknames to the discord and adds a group on ban - I'll put together a push when I finish looking into incorporating BanManager.

commented

This is caused by a bug in older versions of Java so I'm not going to attempt to "fix" this. I have however added an optional parameter to the debug command.

The issue is caused by the JRE not having JCE enabled, something that's enabled by default since around the middle of Java 8's lifecycle. Without JCE, the JVM can only do AES 128-bit. Since the debug handler uses 256 by default, it throws that exception. The parameter I've added allows you to specify to only use 128 bits if you can't control the JVM version you're running on.

/discord debug 128