parent
c0cf28ec86
commit
e96e53c91f
@ -1,14 +1,15 @@ |
||||
* [首页](/?t=1553571028492) |
||||
* [首页](/?t=1553593844358) |
||||
* 开发文档 |
||||
* [快速体验](files/10010_快速体验.md?t=1553571028492) |
||||
* [项目接入到SOP](files/10011_项目接入到SOP.md?t=1553571028520) |
||||
* [新增接口](files/10020_新增接口.md?t=1553571028521) |
||||
* [业务参数校验](files/10030_业务参数校验.md?t=1553571028521) |
||||
* [错误处理](files/10040_错误处理.md?t=1553571028521) |
||||
* [接口交互详解](files/10050_接口交互详解.md?t=1553571028521) |
||||
* [使用SpringCloudGateway](files/10060_使用SpringCloudGateway.md?t=1553571028521) |
||||
* [easyopen支持](files/10070_easyopen支持.md?t=1553571028521) |
||||
* [快速体验](files/10010_快速体验.md?t=1553593844358) |
||||
* [项目接入到SOP](files/10011_项目接入到SOP.md?t=1553593844380) |
||||
* [新增接口](files/10020_新增接口.md?t=1553593844380) |
||||
* [业务参数校验](files/10030_业务参数校验.md?t=1553593844380) |
||||
* [错误处理](files/10040_错误处理.md?t=1553593844380) |
||||
* [接口交互详解](files/10050_接口交互详解.md?t=1553593844380) |
||||
* [使用SpringCloudGateway](files/10060_使用SpringCloudGateway.md?t=1553593844380) |
||||
* [easyopen支持](files/10070_easyopen支持.md?t=1553593844380) |
||||
* [使用签名校验工具](files/10080_使用签名校验工具.md?t=1553593844380) |
||||
* 原理分析 |
||||
* [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1553571028521) |
||||
* [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1553571028521) |
||||
* [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1553571028521) |
||||
* [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1553593844380) |
||||
* [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1553593844381) |
||||
* [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1553593844381) |
||||
|
@ -0,0 +1,48 @@ |
||||
# 使用签名校验工具 |
||||
|
||||
## 生成公私钥 |
||||
|
||||
SOP默认签名算法仿照的是支付宝开放平台,因此我们可以使用支付宝开放平台提供的密钥生成工具,[下载地址](https://docs.open.alipay.com/291/105971/) |
||||
|
||||
工具下载完后,运行工具 |
||||
|
||||
- 秘钥格式选择:PKCS8(JAVA适用) |
||||
- 秘钥长度:2048 |
||||
|
||||
然后点击`生成秘钥`,下面文本框会生成,公私钥,如下图所示: |
||||
|
||||
![示例图](https://gw.alipayobjects.com/zos/skylark/6dbc42cc-6b9b-4691-83f1-e7b875e1a602/2018/png/e6b725d0-8257-4a71-b7a0-f5479c9d43d0.png) |
||||
|
||||
公钥给到开放平台,打开sop-gateway项目中的`ZuulConfig.java`,复制公钥 |
||||
|
||||
```java |
||||
appSecretStore.put(应用ID, 公钥内容); |
||||
``` |
||||
|
||||
- 应用ID(app_id):建议个格式为`yyyyMMddHHmmss+自增ID`,如2019032617262200001 |
||||
- 公钥内容:刚刚生成的公钥字符串 |
||||
|
||||
接着私钥放入客户端进行调用。参见AlipayClientPostTest类 |
||||
|
||||
## 签名校验 |
||||
|
||||
验证工具切换到`签名`tab页 |
||||
|
||||
例如执行com.gitee.sop.AlipayClientPostTest.testPost()方法,控制台会打印如下信息: |
||||
|
||||
``` |
||||
----------- 请求信息 ----------- |
||||
请求参数:charset=utf-8&biz_content={"name":"葫芦娃","id":"1"}&method=alipay.story.get&format=json&app_id=2019032617262200001&sign_type=RSA2&version=1.0×tamp=2019-03-26 17:37:41 |
||||
商户秘钥:MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXJv1pQFqWNA/++OYEV7WYXwexZK/J8LY1OWlP9X0T6wHFOvxNKRvMkJ5544SbgsJpVcvRDPrcxmhPbi/sAhdO4x2PiPKIz9Yni2OtYCCeaiE056B+e1O2jXoLeXbfi9fPivJZkxH/tb4xfLkH3bA8ZAQnQsoXA0SguykMRZntF0TndUfvDrLqwhlR8r5iRdZLB6F8o8qXH6UPDfNEnf/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R47IROdY8qmwqcBAN7Vg2K7r7CPlTKAWTRYMJxCT1Hi5gwJb+CZF3+IeYqsJk2NF2s0w5WJTE70k1BSvQsfIzAIDz2yE1oPHvwVAoGAA6e+xQkVH4fMEph55RJIZ5goI4Y76BSvt2N5OKZKd4HtaV+eIhM3SDsVYRLIm9ZquJHMiZQGyUGnsvrKL6AAVNK7eQZCRDk9KQz+0GKOGqku0nOZjUbAu6A2/vtXAaAuFSFx1rUQVVjFulLexkXR3KcztL1Qu2k5pB6Si0K/uwQ= |
||||
待签名内容:app_id=2019032617262200001&biz_content={"name":"葫芦娃","id":"1"}&charset=utf-8&format=json&method=alipay.story.get&sign_type=RSA2×tamp=2019-03-26 17:37:41&version=1.0 |
||||
签名(sign):JCZMSFkXSjw/4TokyM9/9shyrMl7KxQGIZDHIm7+Bvl49Z816/iF/xXLYjUiPXWAXYfp+HlEs3VVQp1Kjh4tIKuKX/i1+exNVs+ICcqVGBewPSZwiWHGpZTfEUiYOoPyUL/eoRIj7Mvlaow0sI9uP7NXNo0kxEFjUOMCzZA7eKm/pu2FHRXt4OhgXq2Go30K5a9oCbbMc/2xcQCc2+zwvOgV3o0A6eMyeAXDJW+eQ2KLhtlqPQvbRV+xyfSut7TkwYSEuNXVVQAfN2lwAS3ru9CQIs8Uz7lK1ITkLu80yLapZVL7tS1PdxK0e3QYToCWD43Wtuoow4ZdDwwzir90HQ== |
||||
----------- 返回结果 ----------- |
||||
{"alipay_story_get_response":{"msg":"Success","code":"10000","name":"海底小纵队(alipay.story.get)","id":1},"sign":"JCZMSFkXSjw/4TokyM9/9shyrMl7KxQGIZDHIm7+Bvl49Z816/iF/xXLYjUiPXWAXYfp+HlEs3VVQp1Kjh4tIKuKX/i1+exNVs+ICcqVGBewPSZwiWHGpZTfEUiYOoPyUL/eoRIj7Mvlaow0sI9uP7NXNo0kxEFjUOMCzZA7eKm/pu2FHRXt4OhgXq2Go30K5a9oCbbMc/2xcQCc2+zwvOgV3o0A6eMyeAXDJW+eQ2KLhtlqPQvbRV+xyfSut7TkwYSEuNXVVQAfN2lwAS3ru9CQIs8Uz7lK1ITkLu80yLapZVL7tS1PdxK0e3QYToCWD43Wtuoow4ZdDwwzir90HQ=="} |
||||
``` |
||||
|
||||
字符集选UTF-8,签名方式RSA2 |
||||
|
||||
把控制台中的`请求参数`和`商户秘钥`填入文本框中,然后点击`开始签名`,下方会出现待签名内容和sign。 |
||||
|
||||
通过比对判断签名过程是否正确。 |
||||
|
Loading…
Reference in new issue