aivarsda / CertificatePinningLib

Android CertificatePinningLib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CertificatePinningLib

The library allows you to pin the server certificates by using the HttpsURLConnection. You will be able to validate the certificate chain and ensure that one of the pins in the specified/trusted set of SubjectPublicKeyInfos appears in the valid certificate chain.

How To Use

Get it on Google Play

Get it on Google Play Get it on Google Play Get it on Google Play

  • 1. Pinning the connection with HttpsPinner.
    Passing the IPinnerCallback implementing class to the HttpsPinner: httpsPinner.getPinnedHttpsConnectionTask(this).
 private void execPinnedConection()
 {
 	String[] trustedPinsSet 	= new String[] {"a36012xcc17c231ac1ag6b788e610c8k75418t543"};
 	String serverUrl            = "https://YOUR_SERVER_URL";
 
 	HttpsPinner httpsPinner = new HttpsPinner(trustedPinsSet,false);
 	PinnedConnectionRequest  pinnedConnectionRequest = new PinnedConnectionRequest("GET",serverUrl);
 	httpsPinner.getPinnedHttpsConnectionTask(this).execute(pinnedConnectionRequest);
 }
  • 2. Add your logic in the iplementing IPinnerCallback class:
 @Override
 public void onTaskPinningSuccess(PinnedConnectionResponse pinnedConnectionResponse) 
 {
 	 //Your logic on connection pinning success ...//
 }
 @Override
 public void onTaskPinningFailure(PinnedConnectionResponse pinnedConnectionResponse) 
 {
 	 //Your logic on connection pinning failure ...//
 }

Contact Developer

Aivars Dalderis

About

Android CertificatePinningLib


Languages

Language:Java 100.0%