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

增加了小程序同城配送接口和WxMaService增加了API签名支持 #3404

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
第三方平台设置小程序API签名
gexiangdong committed Oct 31, 2024
commit 8205ce9163578f5f38b18c4d64c0bccacbcf08d8
3 changes: 2 additions & 1 deletion weixin-java-miniapp/api-signature-readme.md
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ apiSignatureRsaPrivateKey 在上图中**无**对应,C处右侧是公钥,apiS
1. 如果不先点击「随机生成密钥对」,直接点击「下载私钥」得到的是公钥,公钥在这里没有用途。
2. 打开下载的文件,第一行是「-----BEGIN RSA PRIVATE KEY-----」说明是PKCS1格式私钥。
3. PKCS8格式第一行是「-----BEGIN PRIVATE KEY-----」
4. 转换命令 `openssl pkcs8 -topk8 -inform PEM -outform DER -in PKCS1格式密钥文件名 -out 新的PKCS8格式密钥文件名 -nocrypt`
4. 转换命令 `openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in PKCS1格式密钥文件名 -out 新的PKCS8格式密钥文件名`
5. 如果密钥文件有 PUBLIC KEY 字样,说明下载了公钥,重新生成密钥对,下载私钥


Original file line number Diff line number Diff line change
@@ -361,10 +361,11 @@ public WxMaApiResponse execute(
Map<String, String> headers,
String data)
throws WxErrorException {
String dataForLog = "Headers: " + headers.toString() + " Body: " + data;
return excuteWithRetry(
(uriWithAccessToken) -> executor.execute(uriWithAccessToken, headers, data, WxType.MiniApp),
uri,
data);
dataForLog);
}

private static interface ExecutorAction<R> {
@@ -864,7 +865,7 @@ private String base64Encode(byte[] data) {
@Override
public String postWithSignature(String url, JsonObject jsonObject) throws WxErrorException {
long timestamp = System.currentTimeMillis() / 1000;
String appId = this.getWxMaConfig().getAppid();
String appId = this.getWxMaConfig().getWechatMpAppid();
String rndStr = UUID.randomUUID().toString().replace("-", "").substring(0, 30);
String aesKey = this.getWxMaConfig().getApiSignatureAesKey();
String aesKeySn = this.getWxMaConfig().getApiSignatureAesKeySn();
5 changes: 5 additions & 0 deletions weixin-java-miniapp/src/test/resources/test-config-sample.xml
Original file line number Diff line number Diff line change
@@ -9,4 +9,9 @@
<expiresTime>可以不填写</expiresTime>
<openid>某个用户的openId</openid>
<templateId>模版消息的模版ID</templateId>
<componentApiSignatureAesKey>API签名AES密钥【没有开启API签名不要这条】</componentApiSignatureAesKey>
<componentApiSignatureAesKeySn>API签名AES密钥的序号【没有开启API签名不要这条】</componentApiSignatureAesKeySn>
<componentApiSignatureRsaPrivateKey>API签名RSA私钥的【没有开启API签名不要这条】</componentApiSignatureRsaPrivateKey>
<componentApiSignatureRsaPrivateKeySn>API签名RSA私钥的序【没有开启API签名不要这条】
</componentApiSignatureRsaPrivateKeySn>
</xml>
Original file line number Diff line number Diff line change
@@ -352,19 +352,15 @@ void setWxOpenInfo(
String componentToken,
String componentAesKey);

/** 第三方平台设置API签名 RSA 私钥 */
String getComponentApiSignatureRsaPrivateKey();

void setComponentApiSignatureRsaPrivateKey(String componentApiSignatureRsaPrivateKey);

/** 第三方平台设置API签名 AES KEY */
String getComponentApiSignatureAesKey();

void setComponentApiSignatureAesKey(String componentApiSignatureAesKey);

/** 第三方平台设置API签名 RSA 私钥 序号 */
String getComponentApiSignatureRsaPrivateKeySn();

void setComponentApiSignatureRsaPrivateKeySn(String componentApiSignatureRsaPrivateKeySn);

/** 第三方平台设置API签名 AES key 序号 */
String getComponentApiSignatureAesKeySn();

void setComponentApiSignatureAesKeySn(String componentApiSignatureAesKeySn);
}