Giter Site home page Giter Site logo

arnyminerz / cert4android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitfireat/cert4android

0.0 1.0 0.0 510 KB

Android service + TrustManager for managing custom certificates in an app-private key store

License: GNU General Public License v3.0

Shell 1.24% Kotlin 97.69% AIDL 1.07%

cert4android's Introduction

Development tests Documentation

cert4android

cert4android is a library for Android to manage custom certificates which has been developed for DAVx⁵. Feel free to use it in your own open-source app.

This software is not affiliated to, nor has it been authorized, sponsored or otherwise approved by Google LLC. Android is a trademark of Google LLC.

Generated KDoc: https://bitfireat.github.io/cert4android/

For questions, suggestions etc. use Github discussions. We're happy about contributions! In case of bigger changes, please let us know in the discussions before. Then make the changes in your own repository and send a pull request.

Features

  • uses a service to manage custom certificates
  • supports multiple threads and multiple processes (for instance, if you have an UI and a separate :sync process which should share the certificate information)

How to use

  1. Clone cert4android as a submodule.
  2. Add the submodule to settings.gradle / app/build.gradle.
  3. Create an instance of CustomCertManager (Context is required to connect to the CustomCertService, which manages the custom certificates).
  4. Use this instance as X509TrustManager in your calls (for instance, when setting up your HTTP client). Don't forget to get and use the hostnameVerifier(), too.
  5. Close the instance when it's not required anymore (will disconnect from the CustomCertService, thus allowing it to be destroyed).

Example of initialzing an okhttp client:

val keyManager = ...
CustomCertManager(...).use { trustManager ->
    val sslContext = SSLContext.getInstance("TLS")
    sslContext.init(
        if (keyManager != null) arrayOf(keyManager) else null,
        arrayOf(trustManager),
        null
    )
    val builder = OkHttpClient.Builder()
    builder.sslSocketFactory(sslContext.socketFactory, trustManager)
           .hostnameVerifier(hostnameVerifier)
    val httpClient = builder.build()
    // use httpClient
}

You can overwrite resources when you want, just have a look at the res/strings directory. Especially certificate_notification_connection_security and trust_certificate_unknown_certificate_found should contain your app name.

License

Copyright (C) Ricki Hirner and contributors.

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under the conditions of the GNU GPL v3.

cert4android's People

Watchers

 avatar

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.