From 8f81195336ece2bcb302cd1ceb1568217183964d Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Sun, 24 Apr 2022 04:34:17 +0200 Subject: [PATCH] Try to fix "No SSL cert found bind exception" --- .../server/dispatch/DispatchServer.java | 18 ++++++++++++++---- 1 file changed, 14 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 ea7c1166e..a605fbb81 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -177,10 +177,20 @@ 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(); - KeyStore ks = KeyStore.getInstance("PKCS12"); - ks.load(fis, keystorePassword); - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, keystorePassword); + + try { + KeyStore ks = KeyStore.getInstance("PKCS12"); + ks.load(fis, keystorePassword); + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, keystorePassword); + } catch (Exception e) { + KeyStore ks = KeyStore.getInstance("PKCS12"); + ks.load(fis, "123456"); + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, "123456"); + } catch (Exception e) { + Grasscutter.getLogger().warn("[Dispatch] Error while loading keystore!"); + } sslContext.init(kmf.getKeyManagers(), null, null);