|
@@ -41,12 +41,14 @@ func (d *DefaultRpcClient) WrapSign(request interface{}, doHandler func(ctx cont
|
|
|
utils.FileLog.Error("序列化请求失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- timestamp, nonce, sign, _ := d.signature(string(reqStr), 16)
|
|
|
+ timestamp, nonce, sign, _ := d.signature(reqStr, 16)
|
|
|
+ fmt.Println(string(sign))
|
|
|
ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(
|
|
|
"nonce", nonce,
|
|
|
"timestamp", fmt.Sprintf("%d", timestamp),
|
|
|
"signature", sign,
|
|
|
))
|
|
|
+
|
|
|
err = doHandler(ctx, request)
|
|
|
if err != nil {
|
|
|
utils.FileLog.Error("调用PRC服务失败:%v", err)
|
|
@@ -110,11 +112,12 @@ func (d *DefaultRpcClient) signature(req interface{}, nonceLen int) (timestamp i
|
|
|
Timestamp: timestamp, // 添加时间戳
|
|
|
}
|
|
|
entryData, err := json.Marshal(encryptedStruct)
|
|
|
+
|
|
|
if err != nil {
|
|
|
utils.FileLog.Error("序列化加密后的数据失败: %v", err)
|
|
|
return
|
|
|
}
|
|
|
- fmt.Println(string(entryData))
|
|
|
+
|
|
|
// 使用私钥加密
|
|
|
var privateKey *rsa.PrivateKey
|
|
|
privateKey, err = d.parsePrivateKeyFromPEM([]byte(""))
|
|
@@ -131,12 +134,6 @@ func (d *DefaultRpcClient) signature(req interface{}, nonceLen int) (timestamp i
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 序列化加密后的数据
|
|
|
- encryptedData, err = json.Marshal(encryptedStruct)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Error("序列化加密后的数据失败: %v", err)
|
|
|
- return
|
|
|
- }
|
|
|
// 编码加密后的数据
|
|
|
encodedData = base64.StdEncoding.EncodeToString(encryptedData)
|
|
|
return
|