@@ -912,6 +912,10 @@ public String postWithSignature(String url, JsonObject jsonObject) throws WxErro
912912 String rndStr = UUID .randomUUID ().toString ().replace ("-" , "" ).substring (0 , 30 );
913913 String aesKey = this .getWxMaConfig ().getApiSignatureAesKey ();
914914 String aesKeySn = this .getWxMaConfig ().getApiSignatureAesKeySn ();
915+ String rsaKeySn = this .getWxMaConfig ().getApiSignatureRsaPrivateKeySn ();
916+ if (rsaKeySn == null || rsaKeySn .isEmpty ()) {
917+ throw new SecurityException ("ApiSignatureRsaPrivateKeySn不能为空,请检查配置" );
918+ }
915919
916920 jsonObject .addProperty ("_n" , rndStr );
917921 jsonObject .addProperty ("_appid" , appId );
@@ -956,7 +960,7 @@ public String postWithSignature(String url, JsonObject jsonObject) throws WxErro
956960 String requestJson = reqData .toString ();
957961
958962 // 计算签名 RSA
959- String payload = urlPath + "\n " + appId + "\n " + timestamp + "\n " + requestJson ;
963+ String payload = urlPath + "\n " + appId + "\n " + timestamp + "\n " + rsaKeySn + " \n " + requestJson ;
960964 byte [] dataBuffer = payload .getBytes (StandardCharsets .UTF_8 );
961965 RSAPrivateKey priKey ;
962966 try {
@@ -985,6 +989,7 @@ public String postWithSignature(String url, JsonObject jsonObject) throws WxErro
985989 header .put ("Wechatmp-Signature" , signatureString );
986990 header .put ("Wechatmp-Appid" , appId );
987991 header .put ("Wechatmp-TimeStamp" , String .valueOf (timestamp ));
992+ header .put ("Wechatmp-Serial" , rsaKeySn );
988993 log .debug ("发送请求uri:{}, headers:{}, postData:{}" , url , header , requestJson );
989994 WxMaApiResponse response =
990995 this .execute (ApiSignaturePostRequestExecutor .create (this ), url , header , requestJson );
0 commit comments