mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +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")
|
||||
private static List<byte[]> secureConfigCertificates;
|
||||
private static X509Certificate[] certs = null;
|
||||
private volatile static TrustManagerFactory INSTANCE;
|
||||
private static X509Certificate[] getInternalCertificates() {
|
||||
CertificateFactory certFactory = null;
|
||||
try {
|
||||
|
@ -45,6 +46,7 @@ public static X509Certificate[] getCertificates() {
|
|||
}
|
||||
|
||||
public static TrustManagerFactory getTrustManager() throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException {
|
||||
if(INSTANCE != null) return INSTANCE;
|
||||
if(certs == null) certs = getInternalCertificates();
|
||||
TrustManagerFactory factory = TrustManagerFactory.getInstance("X.509");
|
||||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
|
@ -57,6 +59,7 @@ public static TrustManagerFactory getTrustManager() throws KeyStoreException, No
|
|||
i++;
|
||||
}
|
||||
factory.init(keystore);
|
||||
INSTANCE = factory;
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue