下载证书报:Illegal base64 character 2d
Closed this issue · 2 comments
fengerwoo commented
我的JDK版本 1.8
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@2d6d8735): java.lang.IllegalArgumentException: Illegal base64 character 2d
at picocli.CommandLine.executeUserObject(CommandLine.java:1738)
at picocli.CommandLine.access$900(CommandLine.java:145)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1928)
at picocli.CommandLine.parseWithHandlers(CommandLine.java:2282)
at picocli.CommandLine.run(CommandLine.java:2740)
at picocli.CommandLine.run(CommandLine.java:2677)
at com.elias.CertificateDownloader.main(CertificateDownloader.java:155)
Caused by: java.lang.IllegalArgumentException: Illegal base64 character 2d
at java.util.Base64$Decoder.decode0(Base64.java:714)
at java.util.Base64$Decoder.decode(Base64.java:526)
at java.util.Base64$Decoder.decode(Base64.java:549)
at com.wechat.pay.contrib.apache.httpclient.util.PemUtil.loadPrivateKey(PemUtil.java:36)
at com.elias.CertificateDownloader.downloadCertificate(CertificateDownloader.java:82)
at com.elias.CertificateDownloader.run(CertificateDownloader.java:67)
at picocli.CommandLine.executeUserObject(CommandLine.java:1729)
... 8 more
fengerwoo commented
Illegal base64 character 2d 问题已解决
-f 参数要使用:apiclient_key.pem
但是又出现了新问题
java.security.InvalidKeyException: Illegal key size
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@4fe01803): java.lang.IllegalArgumentException: java.security.InvalidKeyException: Illegal key size
at picocli.CommandLine.executeUserObject(CommandLine.java:1738)
at picocli.CommandLine.access$900(CommandLine.java:145)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1928)
at picocli.CommandLine.parseWithHandlers(CommandLine.java:2282)
at picocli.CommandLine.run(CommandLine.java:2740)
at picocli.CommandLine.run(CommandLine.java:2677)
at com.elias.CertificateDownloader.main(CertificateDownloader.java:155)
Caused by: java.lang.IllegalArgumentException: java.security.InvalidKeyException: Illegal key size
at com.wechat.pay.contrib.apache.httpclient.util.AesUtil.decryptToString(AesUtil.java:42)
at com.elias.CertificateDownloader.decryptAndValidate(CertificateDownloader.java:118)
at com.elias.CertificateDownloader.downloadCertificate(CertificateDownloader.java:103)
at com.elias.CertificateDownloader.run(CertificateDownloader.java:67)
at picocli.CommandLine.executeUserObject(CommandLine.java:1729)
... 8 more
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.implInit(Cipher.java:805)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)
at com.wechat.pay.contrib.apache.httpclient.util.AesUtil.decryptToString(AesUtil.java:35)
... 12 more
fengerwoo commented
java.security.InvalidKeyException: Illegal key size 问题已解决
由于jdk限制策略,导致只能128位key进行加解密,而256位加解密则抛出异常。
Oracle 为我们准备了替换的Jar
将local_policy.jar和US_export_policy.jar 两个Jar包,替换到: jdk目录/jre/lib/security/ 目录下
下载地址:
https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html