Java “PKIX 路径构建失败:无法找到请求目标的有效认证路径”仅在发布版本中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35133863/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 16:21:19  来源:igfitidea点击:

"PKIX path building failed: unable to find valid certification path to requested target" Only in release version

javaintellij-ideassl-certificateshirojava-security

提问by Dineshkumar Ponnusamy

The issue is something tricky. I tried to connect my war file to a Active Directory via LDAPS. While running with Debug Mode from IntelliJ IDEA, the code is working perfectly fine.

这个问题有点棘手。我试图通过 LDAPS 将我的 war 文件连接到 Active Directory。在 IntelliJ IDEA 的调试模式下运行时,代码运行良好。

When I Install the war files in same or different machine, am facing this error.

当我在同一台或不同台机器上安装 war 文件时,遇到此错误。

sun.security.validator.ValidatorException: PKIX path building failed:    sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The certificates are self-signed. I have added the CA.crt in truststore.jks, LDAP.cer in cacerts. I also tried adding in the `jssecacerts', but same result.

证书是自签名的。我在 .crt 中添加了 CA.crt truststore.jks,在cacerts. 我也尝试添加“jssecacerts”,但结果相同。

Note: Am using Apache Shiro framework.

注意:我使用的是 Apache Shiro 框架。

How to avoid this error? Why it is not coming in the debug mode?

如何避免这个错误?为什么它没有进入调试模式?

回答by justin.hughey

This is not a Shiro problem. It is a problem with your certificates. I suspect your IDE may be using a different Java install than where your deployed WAR is executing from.

这不是 Shiro 的问题。你的证书有问题。我怀疑您的 IDE 使用的 Java 安装可能与您部署的 WAR 的执行位置不同。

This exception has been handled previously How to ignore PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException?.

这个异常之前已经处理过How to ignore PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException?.

Also, I found this article useful PKIX path building failed: SunCertPathBuilderException: unable to find valid certification path to requested target..

此外,我发现这篇文章很有用PKIX 路径构建失败:SunCertPathBuilderException:无法找到到请求目标的有效认证路径。.

回答by Akanksha gore

Definitely its problem with certificates. Thing that worked for me was, placing required certificate in C -> program files-> java -> jre -> lib -> securitylocation. After pasting cerificate at this loaction, build successful

肯定是证书的问题。对我有用的是,将所需的证书放在C -> 程序文件 -> java -> jre -> lib -> 安全位置。在此位置粘贴证书后,构建成功