Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 2 of 2
  1. Thread Author  Thread Author    #1  

    Default installing ca certificate programatically

    I am trying to add a CA certificate programatically in a HTC Desire S device Android version 2.3.5 and HTC Sense version 3.0.

    I am using the following code:

    Intent intent = new Intent("android.credentials.INSTALL");
    intent.putExtra("name","testCA");
    intent.putExtra("CERT", bytes);
    startActivityForResult(intent, CA_CERT_ADDED);

    I am populating the variable "bytes" correctly with the certificate bytes. When I run the code the dialog appears stating that I am installing a CA certificate, however the dialog is not populated by the certificate name that I pass in.

    On other types of devices (non htc) I do not have this problem. It is only HTC devices.

    Has anyone else ever come across this before and is there a solution to it.

    Thank you in advance
  2. #2  

    Default Re: installing ca certificate programatically

    Hi
    here comes my code which works perfectly for me.
    I am use Commons IO - Download Commons IO apache library to convert CA to byte array.


    private void showCAInstallationDialog() {
    try {
    InputStream caInputStream = getResources()
    .openRawResource(R.raw.ca);
    if (caInputStream != null) {

    byte[] result;

    result = IOUtils.toByteArray(caInputStream);

    // The next line actually installs the certificate
    Intent intent = new Intent("android.credentials.INSTALL");
    intent.putExtra("name", getString(R.string.app_name) + " CA ");
    intent.putExtra("CERT", result);
    startActivityForResult(intent, CA_CERTIFICATE_ADDED);

    } else {
    Utility.logError(AppName.class.getSimpleName(),
    "Error occurred while reading CA");
    }
    } catch (IOException e) {
    e.printStackTrace();
    }

    }
    Commons IO - Download Commons IO

Similar Threads

  1. Replies: 0
    Last Post: 04-04-2011, 03:27 PM
  2. App Install Failure - Parse Failed No Certificates?
    By MoneyAddyct in forum Android Sideload Wonder Machine
    Replies: 1
    Last Post: 02-24-2011, 12:23 AM
  3. Installing Certificates on Incredible
    By Feldhege in forum Verizon Droid Incredible
    Replies: 6
    Last Post: 08-17-2010, 08:58 PM
  4. Tip - How to update installed apps
    By plifebryan in forum Android Applications
    Replies: 7
    Last Post: 08-06-2010, 02:30 PM
  5. HELP! Installed Handcent. Still at 100%
    By dullgeek in forum HTC Hero
    Replies: 14
    Last Post: 01-04-2010, 08:45 PM

Posting Permissions