[FIX] ServerWrapper

This commit is contained in:
Gravita 2023-12-29 17:07:03 +07:00
parent f321b8bd27
commit 449798d52b

View file

@ -1,6 +1,7 @@
package pro.gravit.launcher.base.request.websockets; package pro.gravit.launcher.base.request.websockets;
import pro.gravit.launcher.base.Downloader; import pro.gravit.launcher.base.Downloader;
import pro.gravit.launcher.core.LauncherInject;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
@ -19,6 +20,8 @@
import java.util.function.Consumer; import java.util.function.Consumer;
public abstract class ClientJSONPoint implements WebSocket.Listener { public abstract class ClientJSONPoint implements WebSocket.Listener {
@LauncherInject("launcher.certificatePinning")
private static boolean isCertificatePinning;
private static final AtomicInteger counter = new AtomicInteger(); private static final AtomicInteger counter = new AtomicInteger();
private final URI uri; private final URI uri;
public boolean isClosed; public boolean isClosed;
@ -49,8 +52,11 @@ public ClientJSONPoint(URI uri) {
else port = 443; else port = 443;
} else port = uri.getPort(); } else port = uri.getPort();
try { try {
httpClient = HttpClient.newBuilder() var httpClientBuilder = HttpClient.newBuilder();
.sslContext(Downloader.makeSSLContext()).build(); if(isCertificatePinning) {
httpClientBuilder = httpClientBuilder.sslContext(Downloader.makeSSLContext());
}
httpClient = httpClientBuilder.build();
webSocketBuilder = httpClient.newWebSocketBuilder().connectTimeout(Duration.ofSeconds(30)); webSocketBuilder = httpClient.newWebSocketBuilder().connectTimeout(Duration.ofSeconds(30));
} catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException | } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException |
KeyManagementException e) { KeyManagementException e) {