Coder Social home page Coder Social logo

ssl-pinning-android's Introduction

SSL-Pinning-Android

๐Ÿ“Œ๐Ÿ“Œ This project will show the implementation of SSL pinning with public key of the server certificate using retrofit okhttp client.

Overview

Github Api has been used to show the ssl pinning. Its a simple user info api which will show user name.After clicking the button github api will be called and it will fetch user data.

Alt text

Explanation

Create CertificatePinner object with hash pin and host name

Alt text

Create OkHttpClient with CertificatePinner object

Alt text

Add OkHttpClient with Retrofit

Alt text

Install Openssl

Mac OS

  • Run this command on terminal brew install openssl

Windows

https://thesecmaster.com/procedure-to-install-openssl-on-the-windows-platform/

How to Extract Public Key/Hash from .cer/.crt file

1st Approach

  • First download the server certificate and save the file in a folder
  • run this command on that folder openssl x509 -in your_cerficate.cer -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64

2nd Appraoch

  • Give a wrong hash in retrofit

Alt text

  • Hit github api then in logcat correct hash pin will be shown. Copy the first hash and use it for pinning

Alt text

3rd Appraoch

  • Run this command openssl s_client -connect www.yourdomain.com:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64

Resources

https://tech.groww.in/ssl-pinning-in-android-part-2-b591dfc8c2f1 https://owasp.org/www-community/controls/Certificate_and_Public_Key_Pinning https://mailapurvpandey.medium.com/ssl-pinning-in-android-90dddfa3e051#:~:text=Public%20Key%20Pinning,-Public%20key%20pinning&text=In%20this%20approach%2C%20we%20generate,throw%20a%20SSL%20certificate%20error.

ssl-pinning-android's People

Contributors

rafi4204 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

indraaslesmana

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.