zoukankan      html  css  js  c++  java
  • 如何将CA证书安装到Android的System下

    当我们需要进行OpenSSL认证时,需要将相应的CA certificate证书安装到系统中,以便实现OpenSSL。证书安装的地方两种,分别是用户级别和系统级别。若是安装到“系统”级别中,可以带来很大的方便。

    现在讲一下如何将CA证书安装到Android的System中,前提是Android手机已经Root啦。

    1.生成Android要求的证书格式

    由于Android系统级别的证书文件名是以‘0’为后缀,以证书的hash值为名字,所以,我们需要根据证书生成对应的hash值,命令如下:

    openssl x509 -inform PEM -subject_hash_old -in ***.pem | head -1

    然后就会生成唯一的hash值,此处的***.pem,是当前的CA证书。假设:生成的hash值为845ea074,那么就像***.pem复制为845ea074.0

    cp ***.pem 845ea074.0

     

    2.将证书安装到System中

    重启adb,作为root启动

    adb root

    获取Android设备上访问/system的权限

    在早期的Android版本中(API LEVEL < 28),需要使用如下命令获得访问权限:

    adb shell "mount -o rw,remount /system"

    API LEVEL >= 29,否则,使用如下命令:

    adb shell "mount -o rw,remount /system"

    将自己的证书push到系统证书目录

    adb push 845ea074.0 /system/etc/security/cacerts
    adb shell "chmod 664 /system/etc/security/cacerts/845ea074.0"

    重启Android系统

    4.将电脑端的证书成为可信任证书

    参考:https://jingyan.baidu.com/article/9f7e7ec0c1107c6f29155461.html 

    5.证书的唯一性

    每个电脑上,使用Charles所产生的证书是不同的。一个比较好的方法是,将有效电脑上的证书复制到一台新的电脑上。

    Charles的证书路径为:AppDataRoamingCharlesdataca

    6.问题

    '/dev/block/dm-0' is read-only

    需要输入一下命令:

    adb root
    adb disable-verity
    adb reboot
    adb root adb remount adb shell mount
    -o rw,remount /system

    这样就确保了有system的访问权限,然后再将证书安装到指定目录下,有两种做法:

    方法一:

    adb push 845ea074.0 /system/etc/security/cacerts
    adb shell "chmod 664 /system/etc/security/cacerts/845ea074.0"

    方法二:

    直接通过Android Stuido中右下边的“Device File Explorer”,将845ea074.0上传到/system/etc/security/cacerts/中

    In order to know build type of your android, in adb shell enter the following command:

    cat /system/build.prop | grep build.type

    参考:

    https://docs.mitmproxy.org/stable/howto-install-system-trusted-ca-android/

    https://blog.csdn.net/xiangguiwang/article/details/76400805

    https://www.jianshu.com/p/47fc5bb61f36?utm_campaign=hugo

  • 相关阅读:
    谢尔宾斯基三角形,“混沌游戏”实现 20141022
    Who are you, What is the science
    The Tao to Excellent 2
    Mac Mini Server安装Centos6.5
    关于ftp的功能类——下载,上传,断点,连接
    mysql http://yaojialing.iteye.com/blog/773973
    序列号
    JS 文件复制
    java MySQLFront_Setup
    牛人博客
  • 原文地址:https://www.cnblogs.com/gwzz/p/13645337.html
Copyright © 2011-2022 走看看