@Override public void run() { try { byte[] keychainBytes; FileInputStream is = null; try { is = new FileInputStream(CERTIFICATE_RESOURCE); keychainBytes = new byte[is.available()]; is.read(keychainBytes); } finally { IOUtils.closeQuietly(is); } Intent intent = KeyChain.createInstallIntent(); intent.putExtra(KeyChain.EXTRA_CERTIFICATE, keychainBytes); intent.putExtra(KeyChain.EXTRA_NAME, "NetworkDiagnosis CA Certificate"); startActivityForResult(intent, 3); } catch (Exception e) { e.printStackTrace(); } } };
@Override public void run() { try { byte[] keychainBytes; FileInputStream is = null; try { is = new FileInputStream(CERTIFICATE_RESOURCE); keychainBytes = new byte[is.available()]; is.read(keychainBytes); } finally { IOUtils.closeQuietly(is); } Intent intent = KeyChain.createInstallIntent(); intent.putExtra(KeyChain.EXTRA_CERTIFICATE, keychainBytes); intent.putExtra(KeyChain.EXTRA_NAME, "NetworkDiagnosis CA Certificate"); startActivityForResult(intent, 3); } catch (Exception e) { e.printStackTrace(); } } };
@Override public void onClick(View v) { try { byte[] keychainBytes; InputStream bis = CaptureActivity.class.getResourceAsStream(CA_RESOURCE); keychainBytes = new byte[bis.available()]; bis.read(keychainBytes); Intent intent = KeyChain.createInstallIntent(); intent.putExtra(KeyChain.EXTRA_CERTIFICATE, keychainBytes); intent.putExtra(KeyChain.EXTRA_NAME, "DreamCatcher CA Certificate"); startActivityForResult(intent, INSTALL_CA_REQUEST_CODE); } catch (Exception e) { e.printStackTrace(); } } });
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = getIntent().getExtras(); if (bundle == null) { finish(); return; } Intent intent = KeyChain.createInstallIntent(); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE_INSTALL); }
private void installPkcs12() { try { // debug - filenames in assets directory String[] f = getAssets().list(""); for(String f1 : f){ Log.v("names",f1); } BufferedInputStream bis = new BufferedInputStream(getAssets().open(PKCS12_FILENAME)); byte[] keychain = new byte[bis.available()]; bis.read(keychain); Intent installIntent = KeyChain.createInstallIntent(); installIntent.putExtra(KeyChain.EXTRA_PKCS12, keychain); startActivity(installIntent); // installIntent.putExtra(KeyChain.EXTRA_NAME, DEFAULT_ALIAS); // startActivityForResult(installIntent, INSTALL_KEYCHAIN_CODE); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }