Android™
Android™
Use a Certificate Vault for Chain Building
See more PFX/P12 Examples
Demonstrates Pfx.UseCertVault, which adds the certificates in an XmlCertVault to the set of sources available for later chain-building operations such as AddCert.
The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.
Background. The call captures a point-in-time snapshot of the vault's certificates. Providing extra intermediate certificates lets Chilkat complete certificate chains when building a PFX.
Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean success = false;
CkPfx pfx = new CkPfx();
// The file path is relative to the application's current working directory. An absolute path
// may also be used. Supply the path appropriate to your own environment.
// Load additional certificates (such as intermediate CA certificates) into a certificate vault.
CkXmlCertVault vault = new CkXmlCertVault();
success = vault.AddCertFile("qa_data/intermediate_ca.cer");
if (success == false) {
Log.i(TAG, vault.lastErrorText());
return;
}
// Make the vault's certificates available as sources for later chain-building operations, such as
// AddCert. The call captures a point-in-time snapshot of the vault's certificates.
success = pfx.UseCertVault(vault);
if (success == false) {
Log.i(TAG, pfx.lastErrorText());
return;
}
Log.i(TAG, "Certificate vault registered as a chain-building source.");
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}