
* `<alias_name>`:为证书指定一个别名,例如 `maven`。 * `<certificate_file>`:证书文件的路径,例如 `~/Desktop/repo.maven.apache.org.cer`。 * `<cacerts_file>`:`cacerts` 文件的路径,例如 `/Library/Java/JavaVirtualMachines/jdk-11.0.16.1.jdk/Contents/Home/lib/security/cacerts`。 示例: ```bash sudo keytool -importcert -alias maven -file ~/Desktop/repo.maven.apache.org.cer -keystore /Library/Java/JavaVirtualMachines/jdk-11.0.16.1.jdk/Contents/Home/lib/security/cacerts ```
3. 导入证书到 intellij idea keystore
IntelliJ IDEA 也有自己的 keystore,用于存储受信任的证书。需要将服务器证书导入到此文件中。
找到 IntelliJ IDEA 的安全目录。通常位于 IntelliJ IDEA.app/Contents/jbr/Contents/Home/lib/security。 注意:IntelliJ IDEA.app 需要替换成你实际安装的 IntelliJ IDEA 应用名称。例如:/Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home/lib/security。 根据你安装的 IntelliJ IDEA 版本,路径可能会有所不同。
使用 keytool 命令导入证书,与导入到 JDK keystore 的步骤相同。
sudo keytool -importcert -alias <alias_name> -file <certificate_file> -keystore <cacerts_file>
示例:
sudo keytool -importcert -alias maven -file ~/Desktop/repo.maven.apache.org.cer -keystore /Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home/lib/security/cacerts
同样,当提示输入密码时,输入 changeit (这是 cacerts 文件的默认密码)。
如果提示是否信任此证书,输入 yes。
4. 重启 IntelliJ IDEA
完成证书导入后,重启 IntelliJ IDEA 使更改生效。
注意事项
总结
通过将服务器证书导入到 JDK 和 IntelliJ IDEA 的 keystore 中,可以解决 PKIX path building failed 错误,使 Java 程序能够安全地连接到 HTTPS 服务。 按照以上步骤操作,可以有效地解决证书信任问题,确保开发环境的稳定性和安全性。
以上就是IntelliJ IDEA 出现 PKIX 路径构建失败的解决方案的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号