mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-03-31 21:44:04 +03:00
[FIX] Оптимизация certificatePinning
This commit is contained in:
parent
bca195ca96
commit
3ccb0c5c8a
1 changed files with 3 additions and 0 deletions
|
@ -21,6 +21,7 @@ public final class CertificatePinningTrustManager {
|
||||||
@LauncherInject("launchercore.certificates")
|
@LauncherInject("launchercore.certificates")
|
||||||
private static List<byte[]> secureConfigCertificates;
|
private static List<byte[]> secureConfigCertificates;
|
||||||
private static X509Certificate[] certs = null;
|
private static X509Certificate[] certs = null;
|
||||||
|
private volatile static TrustManagerFactory INSTANCE;
|
||||||
private static X509Certificate[] getInternalCertificates() {
|
private static X509Certificate[] getInternalCertificates() {
|
||||||
CertificateFactory certFactory = null;
|
CertificateFactory certFactory = null;
|
||||||
try {
|
try {
|
||||||
|
@ -45,6 +46,7 @@ public static X509Certificate[] getCertificates() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrustManagerFactory getTrustManager() throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException {
|
public static TrustManagerFactory getTrustManager() throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException {
|
||||||
|
if(INSTANCE != null) return INSTANCE;
|
||||||
if(certs == null) certs = getInternalCertificates();
|
if(certs == null) certs = getInternalCertificates();
|
||||||
TrustManagerFactory factory = TrustManagerFactory.getInstance("X.509");
|
TrustManagerFactory factory = TrustManagerFactory.getInstance("X.509");
|
||||||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
|
@ -57,6 +59,7 @@ public static TrustManagerFactory getTrustManager() throws KeyStoreException, No
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
factory.init(keystore);
|
factory.init(keystore);
|
||||||
|
INSTANCE = factory;
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue