how to install CA certificate programmatically on Android without user interaction

后端 未结 7 1720
别跟我提以往
别跟我提以往 2020-12-02 11:04

I\'m trying to install certificates without prompting the user. I know this is not good practice, but that\'s what PM wants.

Using KeyChain.createInstallIntent(), I

7条回答
  •  一向
    一向 (楼主)
    2020-12-02 11:29

    Based on the @ospider's answer, i managed to succesfully install the cert like this way:

    adb shell mkdir -p /data/misc/user/0/cacerts-added
    adb push certificate.cer /data/misc/user/0/cacerts-added/807e3b02.0
    
    # Maybe these two lines are not strictly necessary...
    adb shell chmod 644 /data/misc/user/0/cacerts-added/807e3b02.0
    adb shell chown system:system /data/misc/user/0/cacerts-added/807e3b02.0
    

    I got the name of the copied file (807e3b02.0) by installing manually the cert i wanted to automate and seeing how Android saved it (whith adb shell ls -l /data/misc/user/0/cacerts-added/)


    Hope this help.

    Regards.

提交回复
热议问题