bugfix: portbind error when falling back to http server

This commit is contained in:
Alangy 2022-04-24 23:05:08 +08:00
parent a8ed99c94f
commit 4817ed9c52

View File

@ -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) {