Intellij IDE 提供 PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException

问题描述 投票:0回答:1

我收到错误

22:00:17.222 [pool-6-thread-1] ERROR ingrian.internal.xml.XMLAuthToken - handshakeCompleted: SSL handshake did not complete within alloted time {}
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alert.createSSLException(Alert.java:131) ~[?:1.8.0_351]

在我的 Intellij IDE 中,当我运行任何 Java 文件时,但是当我运行

mvn clean install
时,构建会成功。我已经添加了所有必需的证书。 mvn --版本

Maven home: /usr/local/Cellar/maven/3.5.4/libexec
Java version: 1.8.0_351, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home/jre

IDE运行配置

IDE Run Config

Intellij 运行良好,之前,我用新证书替换了旧证书,然后它开始出现此错误。

我已经下载了新的java版本,也下载了新的IDE版本,清除了旧的缓存,但似乎没有任何作用。

Intellij 中是否有任何配置需要更新?

java maven intellij-idea
1个回答
3
投票

我在 Mac 操作系统上遇到此错误。我的问题是在使用 Intellij Idea 时尝试从 Maven Central 下载位于

https://repo.maven.apache.org/maven2/org/slf4j/slf4j-simple/2.0.7/slf4j-simple-2.0.7.pom
中的依赖项。

解决步骤:

    在浏览器上访问
  1. https://repo.maven.apache.org/maven2/org/slf4j/slf4j-simple/2.0.7/slf4j-simple-2.0.7.pom
  2. 点击下图的锁形图标 [![在此处输入图像描述][1]][1] 转到
  3. Connection is secure
    ,然后 
    Certificate is valid
  4. 在“详细信息”选项卡上,选择证书层次结构的最顶层并导出到磁盘上的已知位置。
接下来我们将在两个密钥库上导入证书。首先在我们的 JDK 密钥库上,然后在 IDE 使用的密钥库上。

导入 JDK 密钥库。

  1. 导航到 JAVA_HOME 上的安全文件夹。对于我的情况,请找到

    /Library/Java/JavaVirtualMachines/jdk-11.0.16.1.jdk/Contents/Home/lib/security

    。在此列表中,您将看到一个文件
    cacerts
    ,它是受信任证书的集合。我们需要使用命令 
    sudo keytool -importcert -alias maven -file ~/Desktop/repo.maven.apache.org.cer -keystore cacerts
     导入下载的证书。请注意,在我的例子中,我下载了信任的证书到我的桌面文件夹并命名为 
    repo.maven.apache.org.cer
    。当提示时输入您的密码,作为信任库的
    changeit

  2. 接下来我们需要信任 IDE 安全文件夹中的证书。

    cd /Applications/IntelliJ IDEA 19.05.39.app/Contents/jbr/Contents/Home/lib/security

    。请记下我的 IDE 版本,因为我的位置会根据您使用的 IDE 版本进行一些更改。

  3. 使用

    sudo keytool -importcert -alias maven -file ~/Desktop/repo.maven.apache.org.cer -keystore cacerts

    导入下载的证书。出现提示时输入您的用户密码,并按 
    changeit
     输入密钥库密码。

  4. 重新启动您的 IDE。

© www.soinside.com 2019 - 2024. All rights reserved.