From 79d646d35803bf510e969cb4eef08105de0d90c9 Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Sun, 24 Apr 2022 04:50:22 +0200 Subject: [PATCH] Remove last catch and init another variable as placeholder --- .../emu/grasscutter/server/dispatch/DispatchServer.java | 8 ++++---- 1 file changed, 4 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 deb4faae3..2d36b224e 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -177,11 +177,12 @@ public final class DispatchServer { SSLContext sslContext = SSLContext.getInstance("TLS"); try (FileInputStream fis = new FileInputStream(Grasscutter.getConfig().getDispatchOptions().KeystorePath)) { char[] keystorePassword = Grasscutter.getConfig().getDispatchOptions().KeystorePassword.toCharArray(); - + KeyManagerFactory _kmf; try { KeyStore ks = KeyStore.getInstance("PKCS12"); ks.load(fis, keystorePassword); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + _kmf = kmf; kmf.init(ks, keystorePassword); } catch (Exception e) { Grasscutter.getLogger().warn("[Dispatch] Unable to load keystore. Using default keystore password..."); @@ -189,11 +190,10 @@ public final class DispatchServer { ks.load(fis, "123456".toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, "123456".toCharArray()); - } catch (Exception e) { - Grasscutter.getLogger().warn("[Dispatch] Error while loading keystore!"); + _kmf = kmf; } - sslContext.init(kmf.getKeyManagers(), null, null); + sslContext.init(_kmf.getKeyManagers(), null, null); httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); server = httpsServer;