From 449798d52bd46b64fd82238fef217bc76c0a6c5e Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Fri, 29 Dec 2023 17:07:03 +0700 Subject: [PATCH] [FIX] ServerWrapper --- .../base/request/websockets/ClientJSONPoint.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java index 73f1d9dc..0cc63d33 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java @@ -1,6 +1,7 @@ package pro.gravit.launcher.base.request.websockets; import pro.gravit.launcher.base.Downloader; +import pro.gravit.launcher.core.LauncherInject; import pro.gravit.utils.helper.LogHelper; import javax.net.ssl.SSLException; @@ -19,6 +20,8 @@ import java.util.function.Consumer; public abstract class ClientJSONPoint implements WebSocket.Listener { + @LauncherInject("launcher.certificatePinning") + private static boolean isCertificatePinning; private static final AtomicInteger counter = new AtomicInteger(); private final URI uri; public boolean isClosed; @@ -49,8 +52,11 @@ public ClientJSONPoint(URI uri) { else port = 443; } else port = uri.getPort(); try { - httpClient = HttpClient.newBuilder() - .sslContext(Downloader.makeSSLContext()).build(); + var httpClientBuilder = HttpClient.newBuilder(); + if(isCertificatePinning) { + httpClientBuilder = httpClientBuilder.sslContext(Downloader.makeSSLContext()); + } + httpClient = httpClientBuilder.build(); webSocketBuilder = httpClient.newWebSocketBuilder().connectTimeout(Duration.ofSeconds(30)); } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException | KeyManagementException e) {