wechatpay-apiv3 / certificatedownloader Goto Github PK
View Code? Open in Web Editor NEWJava 微信支付 APIv3 平台证书的命令行下载工具
License: MIT License
Java 微信支付 APIv3 平台证书的命令行下载工具
License: MIT License
JRE版本: 1.8
CertificateDownloader版本: v1.2.0
以下是工具执行的输出内容和报错信息:
body:{"data":[{"effective_time":"2023-10-20T17:13:42+08:00","encrypt_certificate":{"algorithm":"AEAD_AES_256_GCM","associated_data":"certificate","ciphertext":"GlhS6KpGjloLvDcwsfx1IgI9DRJIoFobYcSqlwc2g8bVt9Y+8f9opazMTAntFkwPwsyRHo87LJJwNqaDjbroEwalqueYlljcDH2OIzQHrma/MUkeYidayLKdt5CNbiMWGThicEoHinO+yvXCf5Rp8YjeMlMl5xju1rX/nd87CZXBtYKBDZRGRe8G3oPwECa8KekO6IkFnPD88Yp3dWQhgiso2Yx/macRdNczUlJq8mL2iaM9j4R1vdBhBfRyUlOctGEgRtlJz/ZrZDszs6XvjzOb75LL71gS0/Z35w3kOOYGwGga/A713w1yIT5HHDpg9M4Ooyp3o12hL8R8n2P/7pUPWmUkzL0t2YKwH/Jqk25ZhedClinwutQjvCs5bIlJHZeWlzhsRXhBwzieFOaObmG0Dueo10dkaixpKmQjlJ4iEb77GXLyUSf0ClS3jW7kyH4bNPTJiosSs/NuyrV83BLg++qYD6CPnlgNzEYb1hdwO3HjUo4efvpZpZ/1knXK373ivoZSVyVx8CNcq1lqLXlRIVqn8wC2IYmD5gBIgWdyBsIhvBzMb95vsd6tl9+xnkBtAfUZlG9S0gqMblJ30z91jQ9mwJa93NXC53G1ZJ+e5EzonVktunYMYn/PPbRH8zFZSAFexlx7rTVqkpTxL6UkAVqL12pXbJ6vC1+wkc/j5KkuJ6jGmsEW8SpNS6Rq0kewhSMmVaeKPsqoYyxSUcw3L6y0cC+5aVNlci99MAKzq9RnWzlf6GG1yM8kdnG54LsgCeehZASGHXuMYur8kUC1NU5lP1e8ymUr4sGbqd5Q1Sz1752NxuYZnvNogVZwI6XzrhO4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UXnjo9XhV47Kv38TK89zoaT68NCVjqLcBLUZ3Jkg8h4tWhGokgNPPa60mR0/aT3SUJR43Bd2","nonce":"f5fe2fed4894"},"expire_time":"2028-10-18T17:13:42+08:00","serial_no":"6E953A17FCE93F59EC10DB96DBE12CDAFDB166AD"}]}
javax.crypto.AEADBadTagException: Tag mismatch!
at com.sun.crypto.provider.GaloisCounterMode.decryptFinal(GaloisCounterMode.java:620)
at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:1116)
at com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1053)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
at javax.crypto.Cipher.doFinal(Cipher.java:2168)
at com.wechat.pay.contrib.apache.httpclient.util.AesUtil.decryptToString(AesUtil.java:42)
at com.elias.CertificateDownloader.decryptAndValidate(CertificateDownloader.java:116)
at com.elias.CertificateDownloader.downloadCertificate(CertificateDownloader.java:101)
at com.elias.CertificateDownloader.run(CertificateDownloader.java:65)
at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:2172)
at picocli.CommandLine.parseWithHandlers(CommandLine.java:2559)
at picocli.CommandLine.run(CommandLine.java:3017)
at picocli.CommandLine.run(CommandLine.java:2954)
at com.elias.CertificateDownloader.main(CertificateDownloader.java:153)
release 里面怎么没有了?
指令:java -jar CertificateDownloader-1.1.jar -k ** -m ** -f /apiclient_key.pem -s ** -o .
日志信息:
=== download begin ===
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@5f150435): java.lang.RuntimeException: 无效的密钥格式
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.RuntimeException: 无效的密钥格式
at com.wechat.pay.contrib.apache.httpclient.util.PemUtil.loadPrivateKey(PemUtil.java:40)
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
报错:=== download begin ===
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@18ef96): 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:129)
Caused by: java.lang.IllegalArgumentException: Illegal base64 character 2d
at java.util.Base64$Decoder.decode0(Unknown Source)
at java.util.Base64$Decoder.decode(Unknown Source)
at java.util.Base64$Decoder.decode(Unknown Source)
at com.wechat.pay.contrib.apache.httpclient.util.PemUtil.loadPrivateKey(PemUtil.java:36)
at com.elias.CertificateDownloader.downloadCertificate(CertificateDownloader.java:55)
at com.elias.CertificateDownloader.run(CertificateDownloader.java:105)
at picocli.CommandLine.executeUserObject(CommandLine.java:1729)
... 8 more
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@3e134896): java.lang.IllegalArgumentException: java.security.InvalidKeyException: Illegal key size
PS E:\wxpayv3> java -jar CertificateDownloader.jar -k ${417085cddc0ff8c88e2282541dcc072e} -m ${} -f ${E:\wxpayv3\1482015232_20201223_cert\apiclient_key.pem} -s ${***************************} -o ${E:}
对路径“E:\”的访问被拒绝。
所在位置 行:1 字符: 1
+ CategoryInfo : PermissionDenied: (E:\:String) [], UnauthorizedAccessException
+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.dental.util.wechat.WechatUtils@6d4b1c02): java.lang.IllegalArgumentException: Illegal base64 character 2d
String privateKey = array.toString("utf-8").replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "").replaceAll("\s+", "");
-----BEGIN CERTIFICATE-----
......
-----END CERTIFICATE-----
该 jar 工具,我按文档示例,带上 -c
参数,则会报错
[main] ERROR com.wechat.pay.contrib.apache.httpclient.auth.CertificatesVerifier - 找不到证书序列号对应的证书,序列号:...
不带该参数即可正常,原因不明没有深究。
供各位坑友参考
=== download begin ===
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@6956de9): java.lang.IllegalArgumentException: Illegal base64 character 3f
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 3f
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
我的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
报错:java.io.FileNotFoundException
代码位置:class CertificateDownloader 84 行
代码:
// 这里判断 wechatpayCertificatePath 改成空字符判断 可正常下载
if (wechatpayCertificatePath ==“”) {
//不做验签
builder.withValidator(response -> true);
} else {
List certs = new ArrayList<>();
certs.add(PemUtil.loadCertificate(new FileInputStream(wechatpayCertificatePath)));
builder.withWechatpay(certs);
}
请参阅
贵公司的支付api,宇宙最烂!!!
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.elias.CertificateDownloader@43b0ade): 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
apiV3key为32位字符串
java -jar CertificateDownloader.jar -h
Error: Unable to access jarfile CertificateDownloader.jar
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.