diff --git a/README.md b/README.md
index b15c5cc913..ac2d6e4ee3 100644
--- a/README.md
+++ b/README.md
@@ -339,6 +339,11 @@ cp -R skills/wxjava-* "${CODEX_HOME:-$HOME/.codex}/skills/"
+### 小程序解密与 Bouncy Castle 依赖迁移
+
+- `weixin-java-miniapp` 已移除公开方法 `WxMaCryptUtils.decryptAnotherWay`。解密微信小程序标准会话数据时,使用 `WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr)`。旧方法会将密钥补零至 16 字节的整数倍,并按 AES 的 16 字节分组处理 PKCS#7 填充。`decrypt` 使用原始 AES 密钥和微信的 32 字节填充规则。若业务依赖旧方法的补零或填充行为,应在应用侧保留等价实现,并用历史密文验证。
+- `weixin-java-miniapp`、`weixin-java-pay`、`weixin-java-channel` 和 `weixin-java-store` 不再传递引入 Bouncy Castle。应用直接使用 BC API 时,请显式声明需要的 `org.bouncycastle` 依赖。若应用原先依赖 WxJava 注册名为 `BC` 的 JCA Provider,请改为在应用初始化时注册。
+
---
## 社区交流
diff --git a/weixin-java-channel/pom.xml b/weixin-java-channel/pom.xml
index 10e9d89965..7b7e8d6579 100644
--- a/weixin-java-channel/pom.xml
+++ b/weixin-java-channel/pom.xml
@@ -60,10 +60,6 @@
true
-
- org.bouncycastle
- bcpkix-jdk18on
-
org.projectlombok
lombok
diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
index 3c6d0fd49d..c95c842f3c 100644
--- a/weixin-java-miniapp/pom.xml
+++ b/weixin-java-miniapp/pom.xml
@@ -85,10 +85,6 @@
redis.clients
jedis
-
- org.bouncycastle
- bcpkix-jdk18on
-
org.projectlombok
lombok
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java
index 252297fdcd..c95db1d476 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java
@@ -3,9 +3,6 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.AlgorithmParameters;
-import java.security.Key;
-import java.security.Security;
-import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
@@ -13,7 +10,6 @@
import me.chanjar.weixin.common.error.WxRuntimeException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import me.chanjar.weixin.common.util.crypto.PKCS7Encoder;
@@ -53,37 +49,6 @@ public static String decrypt(String sessionKey, String encryptedData, String ivS
}
- /**
- * AES解密.
- *
- * @param sessionKey session_key
- * @param encryptedData 消息密文
- * @param ivStr iv字符串
- * @return 解密后的字符串
- */
- public static String decryptAnotherWay(String sessionKey, String encryptedData, String ivStr) {
- byte[] keyBytes = Base64.decodeBase64(sessionKey.getBytes(UTF_8));
-
- int base = 16;
- if (keyBytes.length % base != 0) {
- int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
- byte[] temp = new byte[groups * base];
- Arrays.fill(temp, (byte) 0);
- System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
- keyBytes = temp;
- }
-
- Security.addProvider(new BouncyCastleProvider());
- Key key = new SecretKeySpec(keyBytes, "AES");
- try {
- Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
- cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(Base64.decodeBase64(ivStr.getBytes(UTF_8))));
- return new String(cipher.doFinal(Base64.decodeBase64(encryptedData.getBytes(UTF_8))), UTF_8);
- } catch (Exception e) {
- throw new WxRuntimeException("AES解密失败!", e);
- }
- }
-
/**
* 使用用户加密 key 对数据进行 AES-128-CBC 解密(用于小程序加密网络通道).
*
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtilsTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtilsTest.java
index 742fa7d440..2d79be924d 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtilsTest.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtilsTest.java
@@ -20,23 +20,14 @@ public class WxMaCryptUtilsTest {
private static final String ENCRYPT_KEY = "VI6BpyrK9XH4i4AIGe86tg==";
private static final String HEX_IV = "6003f73ec441c3866003f73ec441c386";
+ /**
+ * 验证使用会话密钥解密时按 32 字节分组去掉填充。
+ */
@Test
public void testDecrypt() {
- String sessionKey = "7MG7jbTToVVRWRXVA885rg==";
- String encryptedData = "BY6VOgcWbwGcyrunK0ECWI8rnDsT69DucZ+M78tc1aL9aM/3bEAHFYd4fu7kRjWhD4YfjObw44T9vUqKyHIjbKs6hvtEasZZEIW35x4a91xVgN48ZqZ7MTQqUlP13kDUlkuwYh+/8g8yceu4kNbjowYrhihx+SV7CfjKCveJ7TSepr5Z7aLv1o+rfeelfOwn++WN/YoQsuZ6S3L4fWlWe5DAAUnFUI6cJvxxCohVzbrVXhyH2AqQdSjH2WnMYFeaGFIbcoxMznlk7oEwFn+hBj63dyT/swdYQfEdzuyCBmKXy8d6l1RKVX6Y65coTD8kIlbr+FKsqYrXVUIUBSwehqYuOdhYWZ9Bntl5DWU1oqzAPCnMn2cAIoQpQPKP7IGSxMOvCNAMhVXbE7BvnWuVuGF+AM5tXAa9IVUhcMImGwLQqm4iV5uBd+5OcFObh3A4VJk9iBCBWSkBHa/rV9CVoY0bFv2F9/2Hv82++Ybl274=";
- String ivStr = "TarMFjnzHVxy8pdS93wQbw==";
- System.out.println(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr));
-// System.out.println(WxMaCryptUtils.decryptAnotherWay(sessionKey, encryptedData, ivStr));
- }
-
- @Test
- public void testDecryptAnotherWay() {
- String encryptedData = "CiyLU1Aw2KjvrjMdj8YKliAjtP4gsMZMQmRzooG2xrDcvSnxIMXFufNstNGTyaGS9uT5geRa0W4oTOb1WT7fJlAC+oNPdbB+3hVbJSRgv+4lGOETKUQz6OYStslQ142dNCuabNPGBzlooOmB231qMM85d2/fV6ChevvXvQP8Hkue1poOFtnEtpyxVLW1zAo6/1Xx1COxFvrc2d7UL/lmHInNlxuacJXwu0fjpXfz/YqYzBIBzD6WUfTIF9GRHpOn/Hz7saL8xz+W//FRAUid1OksQaQx4CMs8LOddcQhULW4ucetDf96JcR3g0gfRK4PC7E/r7Z6xNrXd2UIeorGj5Ef7b1pJAYB6Y5anaHqZ9J6nKEBvB4DnNLIVWSgARns/8wR2SiRS7MNACwTyrGvt9ts8p12PKFdlqYTopNHR1Vf7XjfhQlVsAJdNiKdYmYVoKlaRv85IfVunYzO0IKXsyl7JCUjCpoG20f0a04COwfneQAGGwd5oa+T8yO5hzuyDb/XcxxmK01EpqOyuxINew==";
- String ivStr = "r7BXXKkLb8qrSNn05n0qiA==";
- String sessionKey = "tiihtNczf5v6AKRyjwEUhQ==";
-
- assertThat(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr))
- .isEqualTo(WxMaCryptUtils.decryptAnotherWay(sessionKey, encryptedData, ivStr));
+ assertThat(WxMaCryptUtils.decrypt("AQIDBAUGBwgJCgsMDQ4PEA==",
+ "Znhd/z4nX37N0rS/GN8M8y3mlyV+izPMrJpQfPYoOz8=", "AAAAAAAAAAAAAAAAAAAAAA=="))
+ .isEqualTo("miniapp-test");
}
/**
diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
index 3a7a83a0a2..8255c48124 100644
--- a/weixin-java-pay/pom.xml
+++ b/weixin-java-pay/pom.xml
@@ -53,11 +53,6 @@
commons-lang3
-
- org.bouncycastle
- bcpkix-jdk18on
-
-
ch.qos.logback
logback-classic
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java
index 0adc7b1d4a..2b09985d7a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java
@@ -10,19 +10,22 @@
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.util.SignUtils;
import lombok.RequiredArgsConstructor;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMParser;
-import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import javax.crypto.Cipher;
+import javax.crypto.spec.OAEPParameterSpec;
+import javax.crypto.spec.PSource;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileReader;
+import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+import java.security.KeyFactory;
import java.security.PublicKey;
-import java.security.Security;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
@@ -34,6 +37,14 @@
*/
@RequiredArgsConstructor
public class EntPayServiceImpl implements EntPayService {
+ // DER AlgorithmIdentifier for rsaEncryption (1.2.840.113549.1.1.1), with NULL parameters.
+ private static final byte[] RSA_ALGORITHM_IDENTIFIER = {
+ 0x30, 0x0d, 0x06, 0x09, 0x2a, (byte) 0x86, 0x48, (byte) 0x86, (byte) 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00
+ };
+
+ private static final OAEPParameterSpec BANK_OAEP_PARAMETERS =
+ new OAEPParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, PSource.PSpecified.DEFAULT);
+
private final WxPayService payService;
@Override
@@ -174,23 +185,105 @@ public EntPayResult toEmpPay(EntWxEmpPayRequest request) throws WxPayException {
return result;
}
+ /**
+ * 读取付款公钥并按照微信支付 V2 的 OAEP 规则加密字段。
+ *
+ * @param publicKeyFile 微信支付返回的 PEM 公钥文件,支持 PKCS#1 和 SPKI
+ * @param srcString 原始银行卡号或姓名
+ * @return Base64 编码的密文
+ * @throws WxPayException 公钥读取或字段加密失败时
+ */
private String encryptRSA(File publicKeyFile, String srcString) throws WxPayException {
try {
- Security.addProvider(new BouncyCastleProvider());
- Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding");
- try (PEMParser reader = new PEMParser(new FileReader(publicKeyFile))) {
- final PublicKey publicKey = new JcaPEMKeyConverter().setProvider("BC")
- .getPublicKey((SubjectPublicKeyInfo) reader.readObject());
-
- cipher.init(Cipher.ENCRYPT_MODE, publicKey);
- byte[] encrypt = cipher.doFinal(srcString.getBytes(StandardCharsets.UTF_8));
- return Base64.getEncoder().encodeToString(encrypt);
- }
+ PublicKey publicKey = loadBankPublicKey(publicKeyFile.toPath());
+ Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
+ cipher.init(Cipher.ENCRYPT_MODE, publicKey, BANK_OAEP_PARAMETERS);
+ byte[] encrypt = cipher.doFinal(srcString.getBytes(StandardCharsets.UTF_8));
+ return Base64.getEncoder().encodeToString(encrypt);
} catch (Exception e) {
throw new WxPayException("加密出错", e);
}
}
+ /**
+ * 读取第一个 PEM 对象,兼容微信支付默认的 PKCS#1 公钥和 SPKI 公钥。
+ *
+ * @param path PEM 公钥文件路径
+ * @return RSA 公钥
+ * @throws IOException 文件无法读取或 PEM 边界无效时
+ * @throws GeneralSecurityException 公钥无法加载时
+ * @throws IllegalArgumentException PEM 内容不是有效的 Base64 时
+ */
+ private PublicKey loadBankPublicKey(Path path) throws IOException, GeneralSecurityException {
+ try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+ String line;
+ do {
+ line = reader.readLine();
+ } while (line != null && !line.startsWith("-----BEGIN "));
+
+ String header = line == null ? "" : line.trim();
+ boolean pkcs1 = "-----BEGIN RSA PUBLIC KEY-----".equals(header);
+ if (!pkcs1 && !"-----BEGIN PUBLIC KEY-----".equals(header)) {
+ throw new IOException("无效的 RSA 公钥 PEM 头");
+ }
+ String footer = pkcs1 ? "-----END RSA PUBLIC KEY-----" : "-----END PUBLIC KEY-----";
+ StringBuilder encoded = new StringBuilder();
+ while ((line = reader.readLine()) != null && !line.startsWith(footer)) {
+ if (line.indexOf(':') < 0) {
+ encoded.append(line);
+ }
+ }
+ if (line == null) {
+ throw new IOException("缺少 RSA 公钥 PEM 结束标记");
+ }
+ byte[] der = Base64.getDecoder().decode(encoded.toString().replaceAll("\\s+", ""));
+ return KeyFactory.getInstance("RSA")
+ .generatePublic(new X509EncodedKeySpec(pkcs1 ? wrapPkcs1PublicKey(der) : der));
+ }
+ }
+
+ /**
+ * 将 PKCS#1 公钥放入 JDK 所需的 SubjectPublicKeyInfo 结构。
+ *
+ * @param pkcs1 DER 编码的 PKCS#1 公钥
+ * @return DER 编码的 SubjectPublicKeyInfo
+ */
+ private byte[] wrapPkcs1PublicKey(byte[] pkcs1) {
+ byte[] bits = new byte[pkcs1.length + 1];
+ // DER BIT STRING 的首字节是未使用的位数,整字节数据的该值为零。
+ System.arraycopy(pkcs1, 0, bits, 1, pkcs1.length);
+
+ ByteArrayOutputStream content = new ByteArrayOutputStream();
+ content.write(RSA_ALGORITHM_IDENTIFIER, 0, RSA_ALGORITHM_IDENTIFIER.length);
+ writeDer(content, 0x03, bits);
+
+ ByteArrayOutputStream spki = new ByteArrayOutputStream();
+ writeDer(spki, 0x30, content.toByteArray());
+ return spki.toByteArray();
+ }
+
+ /**
+ * 写入一个 DER 标签及其定长内容。
+ *
+ * @param output 编码输出
+ * @param tag 单字节 DER 标签
+ * @param value 待写入的内容
+ */
+ private void writeDer(ByteArrayOutputStream output, int tag, byte[] value) {
+ output.write(tag);
+ int length = value.length;
+ if (length < 128) {
+ output.write(length);
+ } else {
+ int bytes = (Integer.SIZE - Integer.numberOfLeadingZeros(length) + 7) / 8;
+ output.write(0x80 | bytes);
+ for (int shift = (bytes - 1) * 8; shift >= 0; shift -= 8) {
+ output.write(length >>> shift);
+ }
+ }
+ output.write(value, 0, length);
+ }
+
private File buildPublicKeyFile() throws WxPayException {
try {
String publicKeyStr = this.getPublicKey();
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayBankEncryptionTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayBankEncryptionTest.java
new file mode 100644
index 0000000000..e2661f64c2
--- /dev/null
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayBankEncryptionTest.java
@@ -0,0 +1,151 @@
+package com.github.binarywang.wxpay.service.impl;
+
+import com.github.binarywang.wxpay.bean.entpay.EntPayBankRequest;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import me.chanjar.weixin.common.util.XmlUtils;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.testng.annotations.Test;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.OAEPParameterSpec;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * 企业付款到银行卡的公钥兼容性测试
+ *
+ * @author zhangyl
+ * @since 2026-12-02
+ */
+public class EntPayBankEncryptionTest {
+ private static final String TEST_MCH_KEY = "test-only-placeholder";
+
+ /**
+ * 验证 PKCS#1 和 SPKI 公钥均能加密付款请求的银行卡号和姓名,并在加密后签名。
+ *
+ * @throws Exception 生成测试密钥、提交模拟请求或解密失败时
+ */
+ @Test
+ public void testPayBankEncryptsWithBothPublicKeyFormats() throws Exception {
+ KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
+ generator.initialize(2048);
+ KeyPair keyPair = generator.generateKeyPair();
+ byte[] spki = keyPair.getPublic().getEncoded();
+ // 2048 位 RSA 和默认公钥指数的 JDK SPKI 编码,前 24 字节是 RSA 算法和 BIT STRING 外层。
+ byte[] pkcs1 = Arrays.copyOfRange(spki, 24, spki.length);
+
+ for (String pem : Arrays.asList(toPem("RSA PUBLIC KEY", pkcs1, "\r\n"), toPem("PUBLIC KEY", spki, "\n"))) {
+ AtomicReference paymentXml = new AtomicReference<>();
+ new EntPayServiceImpl(mockPayService(pem, paymentXml)).payBank(newBankRequest());
+
+ Map fields = XmlUtils.xml2Map(paymentXml.get());
+ assertThat(fields).containsEntry("mch_id", "test-merchant")
+ .containsEntry("partner_trade_no", "test123456")
+ .containsEntry("bank_code", "1001")
+ .containsEntry("amount", "1");
+ assertThat((String) fields.get("nonce_str")).isNotEmpty().hasSizeLessThanOrEqualTo(32);
+ assertMd5Signature(fields);
+ Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPPadding");
+ cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate(), OAEPParameterSpec.DEFAULT);
+ byte[] bankNo = Base64.getDecoder().decode((String) fields.get("enc_bank_no"));
+ byte[] trueName = Base64.getDecoder().decode((String) fields.get("enc_true_name"));
+ assertThat(new String(cipher.doFinal(bankNo), StandardCharsets.UTF_8))
+ .isEqualTo("1234567890123456");
+ assertThat(new String(cipher.doFinal(trueName), StandardCharsets.UTF_8))
+ .isEqualTo("测试收款人");
+ }
+ }
+
+ /**
+ * 按微信支付 V2 的签名规则,从实际发送的 XML 字段重新计算 MD5。
+ *
+ * @param fields 付款请求 XML 中的字段和值
+ */
+ private void assertMd5Signature(Map fields) {
+ String parameters = new TreeMap<>(fields).entrySet().stream()
+ .filter(field -> !"sign".equals(field.getKey()) && !"".equals(field.getValue()))
+ .map(field -> field.getKey() + "=" + field.getValue())
+ .collect(Collectors.joining("&"));
+ String signature = DigestUtils.md5Hex(parameters + "&key=" + TEST_MCH_KEY).toUpperCase(Locale.ROOT);
+ assertThat(fields.get("sign")).isEqualTo(signature);
+ }
+
+ /**
+ * 验证公钥无效时保留加密异常,且不会发送付款请求。
+ */
+ @Test
+ public void testPayBankRejectsInvalidPublicKeyBeforePosting() {
+ AtomicReference paymentXml = new AtomicReference<>();
+ String pem = toPem("RSA PUBLIC KEY", new byte[]{0x30, 0x00}, "\n");
+ EntPayServiceImpl service = new EntPayServiceImpl(mockPayService(pem, paymentXml));
+
+ assertThatThrownBy(() -> service.payBank(newBankRequest()))
+ .isInstanceOf(WxPayException.class)
+ .hasMessageContaining("加密出错");
+ assertThat(paymentXml.get()).isNull();
+ }
+
+ /**
+ * 构造包含指定公钥的模拟微信支付服务。
+ *
+ * @param pem 模拟接口返回的 PEM 公钥
+ * @param paymentXml 接收付款接口的请求 XML
+ * @return 模拟支付服务
+ */
+ private WxPayServiceImpl mockPayService(String pem, AtomicReference paymentXml) {
+ WxPayServiceImpl service = new WxPayServiceImpl() {
+ @Override
+ public String post(String url, String requestStr, boolean useKey) {
+ assertThat(useKey).isTrue();
+ String success = "SUCCESSSUCCESS";
+ if ("https://fraud.mch.weixin.qq.com/risk/getpublickey".equals(url)) {
+ return success + "";
+ }
+ assertThat(url).isEqualTo("https://api.mch.weixin.qq.com/mmpaysptrans/pay_bank");
+ paymentXml.set(requestStr);
+ return success + "";
+ }
+ };
+ WxPayConfig config = new WxPayConfig();
+ config.setMchId("test-merchant");
+ config.setMchKey(TEST_MCH_KEY);
+ service.setConfig(config);
+ return service;
+ }
+
+ private EntPayBankRequest newBankRequest() {
+ return EntPayBankRequest.builder()
+ .partnerTradeNo("test123456")
+ .bankCode("1001")
+ .amount(1)
+ .encBankNo("1234567890123456")
+ .encTrueName("测试收款人")
+ .build();
+ }
+
+ /**
+ * 编码指定 PEM 类型,使用 64 字符折行。
+ *
+ * @param label PEM 类型
+ * @param der 公钥的 DER 编码
+ * @param eol 换行符
+ * @return PEM 文本
+ */
+ private String toPem(String label, byte[] der, String eol) {
+ return "-----BEGIN " + label + "-----" + eol
+ + Base64.getMimeEncoder(64, eol.getBytes(StandardCharsets.US_ASCII)).encodeToString(der) + eol
+ + "-----END " + label + "-----" + eol;
+ }
+}
diff --git a/weixin-java-pay/src/test/resources/testng.xml b/weixin-java-pay/src/test/resources/testng.xml
index b44e6f3870..dd574c3cf3 100644
--- a/weixin-java-pay/src/test/resources/testng.xml
+++ b/weixin-java-pay/src/test/resources/testng.xml
@@ -48,6 +48,7 @@
+
diff --git a/weixin-java-store/pom.xml b/weixin-java-store/pom.xml
index 62d4764b68..3c5d5a2fe9 100644
--- a/weixin-java-store/pom.xml
+++ b/weixin-java-store/pom.xml
@@ -53,10 +53,6 @@
2.18.8
true
-
- org.bouncycastle
- bcpkix-jdk18on
-
org.projectlombok
lombok