Skip to content

Commit

Permalink
Remove last catch and init another variable as placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
memetrollsXD committed Apr 24, 2022
1 parent 47d34eb commit 40cf40c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,23 @@ public void start() throws Exception {
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...");
KeyStore ks = KeyStore.getInstance("PKCS12");
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;
Expand Down

0 comments on commit 40cf40c

Please sign in to comment.