Search in sources :

Example 1 with TrustStore

use of org.whispersystems.signalservice.api.push.TrustStore in project Signal-Android by WhisperSystems.

the class ContactDiscoveryV2 method getIasKeyStore.

private static KeyStore getIasKeyStore(@NonNull Context context) {
    try {
        TrustStore contactTrustStore = new IasTrustStore(context);
        KeyStore keyStore = KeyStore.getInstance("BKS");
        keyStore.load(contactTrustStore.getKeyStoreInputStream(), contactTrustStore.getKeyStorePassword().toCharArray());
        return keyStore;
    } catch (KeyStoreException | CertificateException | IOException | NoSuchAlgorithmException e) {
        throw new AssertionError(e);
    }
}
Also used : CertificateException(java.security.cert.CertificateException) TrustStore(org.whispersystems.signalservice.api.push.TrustStore) IasTrustStore(org.thoughtcrime.securesms.push.IasTrustStore) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStore(java.security.KeyStore) IasTrustStore(org.thoughtcrime.securesms.push.IasTrustStore)

Example 2 with TrustStore

use of org.whispersystems.signalservice.api.push.TrustStore in project Signal-Android by WhisperSystems.

the class IasKeyStore method getIasKeyStore.

public static KeyStore getIasKeyStore(@NonNull Context context) {
    try {
        TrustStore contactTrustStore = new IasTrustStore(context);
        KeyStore keyStore = KeyStore.getInstance("BKS");
        keyStore.load(contactTrustStore.getKeyStoreInputStream(), contactTrustStore.getKeyStorePassword().toCharArray());
        return keyStore;
    } catch (KeyStoreException | CertificateException | IOException | NoSuchAlgorithmException e) {
        throw new AssertionError(e);
    }
}
Also used : CertificateException(java.security.cert.CertificateException) IasTrustStore(org.thoughtcrime.securesms.push.IasTrustStore) TrustStore(org.whispersystems.signalservice.api.push.TrustStore) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStore(java.security.KeyStore) IasTrustStore(org.thoughtcrime.securesms.push.IasTrustStore)

Example 3 with TrustStore

use of org.whispersystems.signalservice.api.push.TrustStore in project Signal-Android by signalapp.

the class BadgeLoader method createFactory.

public static Factory createFactory() {
    try {
        OkHttpClient baseClient = ApplicationDependencies.getOkHttpClient();
        SSLContext sslContext = SSLContext.getInstance("TLS");
        TrustStore trustStore = new SignalServiceTrustStore(ApplicationDependencies.getApplication());
        TrustManager[] trustManagers = BlacklistingTrustManager.createFor(trustStore);
        sslContext.init(null, trustManagers, null);
        OkHttpClient client = baseClient.newBuilder().sslSocketFactory(new Tls12SocketFactory(sslContext.getSocketFactory()), (X509TrustManager) trustManagers[0]).connectionSpecs(Util.immutableList(ConnectionSpec.RESTRICTED_TLS)).build();
        return new Factory(client);
    } catch (NoSuchAlgorithmException | KeyManagementException e) {
        throw new AssertionError(e);
    }
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MultiModelLoaderFactory(com.bumptech.glide.load.model.MultiModelLoaderFactory) Tls12SocketFactory(org.whispersystems.signalservice.api.util.Tls12SocketFactory) ModelLoaderFactory(com.bumptech.glide.load.model.ModelLoaderFactory) SSLContext(javax.net.ssl.SSLContext) SignalServiceTrustStore(org.thoughtcrime.securesms.push.SignalServiceTrustStore) TrustStore(org.whispersystems.signalservice.api.push.TrustStore) Tls12SocketFactory(org.whispersystems.signalservice.api.util.Tls12SocketFactory) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SignalServiceTrustStore(org.thoughtcrime.securesms.push.SignalServiceTrustStore) KeyManagementException(java.security.KeyManagementException) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager) BlacklistingTrustManager(org.whispersystems.signalservice.internal.util.BlacklistingTrustManager)

Example 4 with TrustStore

use of org.whispersystems.signalservice.api.push.TrustStore in project Signal-Android by WhisperSystems.

the class BadgeLoader method createFactory.

public static Factory createFactory() {
    try {
        OkHttpClient baseClient = ApplicationDependencies.getOkHttpClient();
        SSLContext sslContext = SSLContext.getInstance("TLS");
        TrustStore trustStore = new SignalServiceTrustStore(ApplicationDependencies.getApplication());
        TrustManager[] trustManagers = BlacklistingTrustManager.createFor(trustStore);
        sslContext.init(null, trustManagers, null);
        OkHttpClient client = baseClient.newBuilder().sslSocketFactory(new Tls12SocketFactory(sslContext.getSocketFactory()), (X509TrustManager) trustManagers[0]).connectionSpecs(Util.immutableList(ConnectionSpec.RESTRICTED_TLS)).build();
        return new Factory(client);
    } catch (NoSuchAlgorithmException | KeyManagementException e) {
        throw new AssertionError(e);
    }
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MultiModelLoaderFactory(com.bumptech.glide.load.model.MultiModelLoaderFactory) Tls12SocketFactory(org.whispersystems.signalservice.api.util.Tls12SocketFactory) ModelLoaderFactory(com.bumptech.glide.load.model.ModelLoaderFactory) SSLContext(javax.net.ssl.SSLContext) SignalServiceTrustStore(org.thoughtcrime.securesms.push.SignalServiceTrustStore) TrustStore(org.whispersystems.signalservice.api.push.TrustStore) Tls12SocketFactory(org.whispersystems.signalservice.api.util.Tls12SocketFactory) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SignalServiceTrustStore(org.thoughtcrime.securesms.push.SignalServiceTrustStore) KeyManagementException(java.security.KeyManagementException) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager) BlacklistingTrustManager(org.whispersystems.signalservice.internal.util.BlacklistingTrustManager)

Example 5 with TrustStore

use of org.whispersystems.signalservice.api.push.TrustStore in project Signal-Android by signalapp.

the class IasKeyStore method getIasKeyStore.

public static KeyStore getIasKeyStore(@NonNull Context context) {
    try {
        TrustStore contactTrustStore = new IasTrustStore(context);
        KeyStore keyStore = KeyStore.getInstance("BKS");
        keyStore.load(contactTrustStore.getKeyStoreInputStream(), contactTrustStore.getKeyStorePassword().toCharArray());
        return keyStore;
    } catch (KeyStoreException | CertificateException | IOException | NoSuchAlgorithmException e) {
        throw new AssertionError(e);
    }
}
Also used : CertificateException(java.security.cert.CertificateException) IasTrustStore(org.thoughtcrime.securesms.push.IasTrustStore) TrustStore(org.whispersystems.signalservice.api.push.TrustStore) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStore(java.security.KeyStore) IasTrustStore(org.thoughtcrime.securesms.push.IasTrustStore)

Aggregations

NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 TrustStore (org.whispersystems.signalservice.api.push.TrustStore)6 IOException (java.io.IOException)4 KeyStore (java.security.KeyStore)4 KeyStoreException (java.security.KeyStoreException)4 CertificateException (java.security.cert.CertificateException)4 IasTrustStore (org.thoughtcrime.securesms.push.IasTrustStore)4 ModelLoaderFactory (com.bumptech.glide.load.model.ModelLoaderFactory)2 MultiModelLoaderFactory (com.bumptech.glide.load.model.MultiModelLoaderFactory)2 KeyManagementException (java.security.KeyManagementException)2 SSLContext (javax.net.ssl.SSLContext)2 TrustManager (javax.net.ssl.TrustManager)2 X509TrustManager (javax.net.ssl.X509TrustManager)2 OkHttpClient (okhttp3.OkHttpClient)2 SignalServiceTrustStore (org.thoughtcrime.securesms.push.SignalServiceTrustStore)2 Tls12SocketFactory (org.whispersystems.signalservice.api.util.Tls12SocketFactory)2 BlacklistingTrustManager (org.whispersystems.signalservice.internal.util.BlacklistingTrustManager)2