-
-
Save maplerise/0416a4a122cc15abf80f44d8cf8aa8aa to your computer and use it in GitHub Desktop.
Builds client with interceptor, pinner, and verifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App extends Application { | |
// ... | |
@Override | |
public void onCreate (){ | |
super.onCreate(); | |
mPlatformSpecifics = new AndroidPlatformSpecifics(this); | |
mAttestation = new ApproovAttestation(mPlatformSpecifics); | |
try { | |
SSLContextPinner pinner = new SSLContextPinner("cert.pem"); | |
mClient = new OkHttpClient.Builder() | |
.sslSocketFactory(pinner.getSSLContext().getSocketFactory(), pinner.getX509TrustManager()) | |
.hostnameVerifier(new NoHostnameVerifier()) | |
.addInterceptor(new ApproovInterceptor(mAttestation)) | |
.build(); | |
} catch (Exception e) { | |
Log.e("App", e.toString()); | |
Log.e("App", "Failed to pin connection"); | |
throw new IllegalStateException("Failed to pin connection:"); | |
} | |
mDownloader = new Picasso.Builder(this) | |
.downloader(new OkHttp3Downloader(mClient)) | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment