diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java index 482fb76e64..b20875ef2b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java @@ -199,8 +199,12 @@ public boolean handle(EncryptionResponsePacket packet) { } byte[] decryptedSharedSecret = decryptRsa(serverKeyPair, packet.getSharedSecret()); - String serverId = generateServerId(decryptedSharedSecret, serverKeyPair.getPublic()); + // Go ahead and enable encryption. Once the client sends EncryptionResponse, encryption + // is enabled. + mcConnection.enableEncryption(decryptedSharedSecret); + + String serverId = generateServerId(decryptedSharedSecret, serverKeyPair.getPublic()); String playerIp = ((InetSocketAddress) mcConnection.getRemoteAddress()).getHostString(); String url = String.format(MOJANG_HASJOINED_URL, urlFormParameterEscaper().escape(login.getUsername()), serverId); @@ -229,18 +233,6 @@ public boolean handle(EncryptionResponsePacket packet) { return; } - // Go ahead and enable encryption. Once the client sends EncryptionResponse, encryption - // is enabled. - try { - mcConnection.enableEncryption(decryptedSharedSecret); - } catch (GeneralSecurityException e) { - logger.error("Unable to enable encryption for connection", e); - // At this point, the connection is encrypted, but something's wrong on our side and - // we can't do anything about it. - mcConnection.close(true); - return; - } - if (response.statusCode() == 200) { final GameProfile profile = GENERAL_GSON.fromJson(response.body(), GameProfile.class);