mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] ServerWrapper
This commit is contained in:
parent
f321b8bd27
commit
449798d52b
1 changed files with 8 additions and 2 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue