内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
当我在Android Studio中创建一个新项目时显示它:
Server's certificate is not trusted
Certificate details
Issued To
CN (Common Name) *.google.com
O (Organization) Google Inc
L (Locality) Mountain View
C (Country) US
ST (State or Province) California
Issued By
CN (Common Name) Google Internet Authority G2
O (Organization) Google Inc
C (Country) US
Validity Period
Valid from: 9/24/14
Valid until: 12/23/14
...
忽视该警告是不安全的。有人可能会尝试用假证书进行中间人攻击,以便通过更新过程在你的计算机上安装恶意软件。这可能没有发生,但在安全方面正确地做事总是更好。
你应该将你信任的根证书添加到Android Studio密钥库。密钥库的位置和默认密码应列在该警告的底部。例如,我的是~/Library/Caches/AndroidStudio/tasks/cacerts
。接下来,你需要在服务器呈现的链中找到根证书。不幸的是,这个警告并没有列出整个链条,因此需要一点努力才能找到它。该Google Internet Authority G2
证书与用于签署Google网站证书的证书相同。你可以转到google.com,点击绿色锁,然后点击连接标签中的“证书信息”,查看Chrome中的链。此时,你可以验证警告中的哈希与真正的G2证书的哈希匹配。你还会看到根证书已命名Equifax Secure Certificate Authority
。https://www.geotrust.com/resources/root-certificates/。接下来,你需要将其添加到密钥库:
keytool -import -alias equifaxca \
-file Equifax_Secure_Certificate_Authority.pem -keystore cacerts