diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index f681baa60..6d8a06e7c 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -200,6 +200,8 @@ 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; @@ -232,9 +234,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) {