天天看點

Android之獲驗證書檔案(pfx格式)的公鑰和私鑰

1、把pfx證書檔案放入sdcard

adb push    ***.pfx /sdcard/
           

2、解析擷取公鑰和私鑰

//證書解析
String path = Environment.getExternalStorageDirectory().getPath() + "/sim_shield.pfx";

   public static Map<String, byte[]> parsePfx(String pfxPath, String pwd) {
    	Map<String, byte[]> keyMap = new HashMap<String, byte[]>();
    	 try {
             KeyStore ks = KeyStore.getInstance("PKCS12");
             FileInputStream fis = null;
             try {
            	 fis = new FileInputStream(pfxPath);
             } catch (Exception e) {
            	 Log.i("sss", "new FileInputStream fail");
             }
             char[] nPassword = pwd.toCharArray();
             ks.load(fis, nPassword);
             fis.close();

             Enum