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

使用jdk21的时候,企业微信会话存档解密报错IllegalAccessError #3211

Closed
ideaviewes opened this issue Jan 10, 2024 · 2 comments · Fixed by #3216
Closed

使用jdk21的时候,企业微信会话存档解密报错IllegalAccessError #3211

ideaviewes opened this issue Jan 10, 2024 · 2 comments · Fixed by #3216

Comments

@ideaviewes
Copy link

ideaviewes commented Jan 10, 2024

简要描述

使用jdk21的时候,企业微信会话存档解密报错IllegalAccessError

模块版本情况

  • WxJava 模块名: wx-java-cp-multi-spring-boot-starter
  • WxJava 版本号: 4.6.0
  • Jdk 版本号 Oracle GraalVM 21.0.1+12.1
  • Springboot 版本号:3.2.1

详细描述

   @Resource
    private WxCpMultiServices wxCpMultiServices;
    @GetMapping("/")
    public WxCpChatDatas index(
            @RequestParam(value = "seq") Long seq
    ) throws Exception {
        WxCpService wxCpService = wxCpMultiServices.getWxCpService("niurensheji");
        WxCpMsgAuditService auditService = wxCpService.getMsgAuditService();

        WxCpChatDatas datas = auditService.getChatDatas(seq, 100, null, null, 1000);
        List<String> list=new ArrayList<>();
        List<WxCpChatDatas.WxCpChatData> data = datas.getChatData();
        Long sdk = datas.getSdk();
        for (WxCpChatDatas.WxCpChatData item : data) {
            String decryptData = auditService.getChatPlainText(sdk, item, 1);
            list.add(decryptData);
        }
        return datas;
    }

代码是这样的,解密的时候报的错,

日志

如果日志不多,直接使用md代码引用格式贴在此处,否则如果太长,请将日志放在 pastebin 或者其他地方,然后将其url地址贴在这里

日志请写于此处
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.IllegalAccessError: class me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil (in unnamed module @0x2d2e5f00) cannot access class sun.security.util.DerInputStream (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x2d2e5f00] with root cause

java.lang.IllegalAccessError: class me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil (in unnamed module @0x2d2e5f00) cannot access class sun.security.util.DerInputStream (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x2d2e5f00
        at me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil.decryptPriKeyByPKCS1(WxCpCryptUtil.java:108) ~[weixin-java-cp-4.6.0.jar!/:na]

@binarywang
Copy link
Owner

jdk21还没用过,没研究过相关问题。
你如果有修复方案,欢迎直接 PR。

@ideaviewes
Copy link
Author

jdk21还没用过,没研究过相关问题。 你如果有修复方案,欢迎直接 PR。

我暂时是在项目启动的时候加了jvm的参数
-add-opens=java.base/sun.security.util=ALL-UNNAMED
可以成功解码了,但是只是临时的方法

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