Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https问题PKIX path building failed #8

Closed
sloooda opened this issue Jun 28, 2016 · 6 comments
Closed

https问题PKIX path building failed #8

sloooda opened this issue Jun 28, 2016 · 6 comments

Comments

@sloooda
Copy link

sloooda commented Jun 28, 2016

在使用普通模式发送消息时,只设置了corpid、corpsecret、agentid三个参数:
WxCpInMemoryConfigStorage config = new WxCpInMemoryConfigStorage();
config.setCorpId("..."); // 设置微信企业号的appid
config.setCorpSecret("..."); // 设置微信企业号的app corpSecret
config.setAgentId("0"); // 设置微信企业号应用ID
报错:
Exception in thread "main" java.lang.RuntimeException: 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 me.chanjar.weixin.cp.api.WxCpServiceImpl.getAccessToken(WxCpServiceImpl.java:128)

@chairmanview
Copy link
Member

binarywang pushed a commit that referenced this issue Dec 9, 2016
@izyh
Copy link

izyh commented Aug 7, 2017

请问这个问题解决了吗?我替换了JCE无限制权限策略文件后还是不行。

@chanjarster
Copy link
Collaborator

@izyh 这个问题可能是微信的https证书不在JDK自带的证书库里,试试看用这个项目解决:

https://github.com/escline/InstallCert

@goodluck028
Copy link

goodluck028 commented Mar 6, 2020

我试了网上的几种方法都不行,干脆重装了jdk,然后就好了。

@nadirvishun
Copy link

nadirvishun commented May 27, 2020

同遇到此问题,重装jdk仍然不管用。个人感觉主要原因就是企业微信所用证书更换了,而java并不认识此证书。
试过的方法:

  • 直接谷歌浏览器访问https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ID&corpsecret=SECRET,然后浏览器中下载证书(导出dre和base64格式都不行),导入后仍不管用。
  • @chanjarster 提供的库下载的证书导入后可正常使用,唯一需要注意的是此库检测的jre路径可能是单独安装的jre路径D:\Java\jre1.8.0_202\lib\security,但我这边在idea中用的是jdk下的jre路径D:\Java\jdk1.8.0_202\jre\lib\security,所以如果不行,两个位置都装一下试试。

还有就是推荐查看证书的工具:KeyStore Explorer,省的用命令行看了,还可以按照安装时间排序什么的。


我个人情况来说,上面的方法虽然可行,但是经常是一开始报错,多次测试后才会持续一段时间不报错,重打开电脑又会报错,但在其它电脑上没有问题,这台电脑原先动过证书方面的,怀疑电脑证书有问题,感觉如果上述方法也不行,重装系统才是最终解决方法。


目前升级了Win10,大版本升级,从1909升级到了20H2,正常了。。。。

@xusir13

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants