Skip to content

Commit

Permalink
First change didn't work. Take 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Valdez committed Aug 28, 2024
1 parent edbd288 commit ca2f398
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions Simperium/src/main/java/com/simperium/android/AndroidClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
Expand All @@ -25,6 +26,8 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;

Expand Down Expand Up @@ -82,11 +85,21 @@ public AndroidClient(Context context){

mSessionId = String.format("%s-%s", Version.LIBRARY_NAME, sessionToken);

TrustManager[] trustManagers = new TrustManager[] {
buildPinnedTrustManager(context),
loadCertificate(context, R.raw.isrgrootx1),
loadCertificate(context, R.raw.isrgrootx2)
};
try {
final SSLContext sslContext = SSLContext.getInstance("TLS");
final TrustManager[] customTrustManagers = new TrustManager[]{
loadCertificate(context, R.raw.isrgrootx1),
loadCertificate(context, R.raw.isrgrootx2)
};
sslContext.init(null, customTrustManagers, null);
mHttpClient.getSSLSocketMiddleware().setSSLContext(sslContext);
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Problem getting instance of SSLContext");
} catch (KeyManagementException e) {
Log.e(TAG, "Problem trying to init SSLContext");
}

TrustManager[] trustManagers = new TrustManager[] { buildPinnedTrustManager(context) };
mHttpClient.getSSLSocketMiddleware().setTrustManagers(trustManagers);

}
Expand Down

0 comments on commit ca2f398

Please sign in to comment.