This is a demo application highlighting how to use the KeyChain APIs introduced in API Level 14.
The source code for this demo app shows how to install a PKCS12 key chain stored in the assets folder, grant permission to the app to use the installed key chain and finally display the certificate and private key info. The app also has a simple implementation of a web server listening to requests at an SSL socket using the same certificate in the key chain.
The application includes the following key classes:
KeyChainDemoActivity
— the main Activity
that is used to install the key chain and start/stop
the web server. SecureWebServer
— a single thread web server listening at port 8080 for https://localhost:8080
requestSecureWebServerService
— a Service
that runs the web server in the foreground.If you are developing an application that uses the KeyChain APIs, remember that the feature is supported only on Android 4.0 (API level 14) and higher versions of the platform. To ensure that your application can only be installed on devices that are running Android 4.0, remember to add the following to the application's manifest:
<uses-sdk android:minSdkVersion="14" />
, which
indicates to the Android platform that your application requires
Android 4.0 or higher. For more information, see API Levels and the
documentation for the <uses-sdk>
element.Note: Due to browser cache, you need to restart the browser completely before it can recognize any keystore updates. The easiest way to do this is to dismiss the app in the Recent Apps list.
For more information about using the KeyChain API, see the
android.security.KeyChain
documentation.