如何在模拟器中将 CA 证书导入 Android 4.4.2?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21206920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I import a CA certificate into Android 4.4.2 in the emulator?
提问by Crypto
I tried both DER and PEM formats. I tried using the file extensions crt, cer, p12, pem but nothing of them get imported. I went into Settings > Security > Install from SD card and it takes me to the Downloads page. I have the certificates listed but when I click on them, nothing happens.
我尝试了 DER 和 PEM 格式。我尝试使用文件扩展名 crt、cer、p12、pem,但没有导入。我进入“设置”>“安全”>“从 SD 卡安装”,它会将我带到“下载”页面。我列出了证书,但是当我点击它们时,没有任何反应。
Updated to add: I ended up going back to 4.3. It works fine in that.
更新添加:我最终回到了 4.3。它在这方面工作得很好。
回答by user2846469
- Go to Android Virtual Device Manager (sdk\tools\android.bat avd)
- Start your emulator but select 'Wipe user Data' when you're starting the emulator
- Copy your certificate into /storage/sdcard using e.g. sdk/tools/monitor.bat
- Set a screenlock pin here: Settings > Security > Screenlock > PIN
- Now you can import the certificate properly via Settings > Security > Install from storage
- 转到 Android 虚拟设备管理器 (sdk\tools\android.bat avd)
- 启动模拟器,但在启动模拟器时选择“擦除用户数据”
- 使用例如 sdk/tools/monitor.bat 将您的证书复制到 /storage/sdcard
- 在此处设置屏幕锁定引脚:设置 > 安全 > 屏幕锁定 > PIN
- 现在您可以通过设置>安全>从存储安装正确导入证书
Background: I also had the same problem you described and it seems to be an android emulator 4.4.2 bug which occurs when you don't import the certificate first thing i.e. when you don't follow the exact steps above.
背景:我也遇到了您描述的相同问题,这似乎是一个 android 模拟器 4.4.2 错误,当您不首先导入证书时,即当您不遵循上述确切步骤时,就会发生该错误。
回答by Crypto
Problem with *.p12 files (pkcs12):
*.p12 文件 (pkcs12) 的问题:
at: Settings -> Security -> Install from SD card the *.p12 files are grayed out. When I download the file via webserver and try to open it, android say me "Can't open" Same with *.pem files. I tried it with 4.4.2 and 4.4.4.
在:设置 -> 安全 -> 从 SD 卡安装 *.p12 文件是灰色的。当我通过网络服务器下载文件并尝试打开它时,android 说我“无法打开”与 *.pem 文件相同。我用 4.4.2 和 4.4.4 试过了。
回答by bunbun
With your limited description, I'll try to help as much as I can.
由于您的描述有限,我会尽力提供帮助。
Ensure your problematic AVD (4.4 I assume) has available storage space. Try best to ensure it is a clean AVD with nothing extra installed.
确保有问题的 AVD(我假设为 4.4)有可用的存储空间。尽量确保它是一个干净的 AVD,没有安装任何额外的东西。
Place your cert in the root /sdcard/ and install at: Settings -> Security -> Install from SD card
将您的证书放在根目录 /sdcard/ 并安装在:设置 -> 安全 -> 从 SD 卡安装
Avoid installation of certs with the same name but different formats.
避免安装名称相同但格式不同的证书。
回答by Maximilian Hils
There is a script available at https://github.com/mitmproxy/mitmproxy/issues/204#issuecomment-32837093.
https://github.com/mitmproxy/mitmproxy/issues/204#issuecomment-32837093 上有一个脚本 。