From 4817ed9c5266de2d589ce998bec04d1b03e88a34 Mon Sep 17 00:00:00 2001 From: Alangy Date: Sun, 24 Apr 2022 23:05:08 +0800 Subject: [PATCH] bugfix: portbind error when falling back to http server --- .../emu/grasscutter/server/dispatch/DispatchServer.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 6d8a06e7c..f681baa60 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -200,8 +200,6 @@ public final class DispatchServer { public void start() throws Exception { HttpServer server; if (Grasscutter.getConfig().getDispatchOptions().UseSSL) { - HttpsServer httpsServer = HttpsServer.create(getAddress(), 0); - SSLContext sslContext = SSLContext.getInstance("TLS"); try (FileInputStream fis = new FileInputStream(Grasscutter.getConfig().getDispatchOptions().KeystorePath)) { char[] keystorePassword = Grasscutter.getConfig().getDispatchOptions().KeystorePassword.toCharArray(); KeyManagerFactory _kmf; @@ -234,9 +232,9 @@ public final class DispatchServer { throw originalEx; } } - + SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(_kmf.getKeyManagers(), null, null); - + HttpsServer httpsServer = HttpsServer.create(getAddress(), 0); httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); server = httpsServer; } catch (BindException ignored) {