向 Swish API 发送有效负载时出现签名问题
我正在尝试使用TLS和签名证书将有效载荷发送到Swish(瑞典支付系统)。我目前正在与商人使用模拟器,并使用测试认证来自Swish文档。
在发送有效载荷和签名时(到EndPont /api/v1/payouts )我会得到此错误:
{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Tue, 12 Apr 2022 07:02:19 GMT
Server: openresty/1.15.8.3
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Transfer-Encoding: chunked
Content-Type: application/json
}}
下面的代码用于生成
var payloadJson = JsonConvert.SerializeObject(payload, Formatting.None, serializerSettings);
var payloadJsonBuffer = Encoding.UTF8.GetBytes(payloadJson);
using var sha512 = SHA512.Create();
var hashedBuffer = sha512.ComputeHash(payloadJsonBuffer);
using var rsa = signCert.GetRSAPrivateKey();
var signedBuffer = rsa.SignHash(hashedBuffer, HashAlgorithmName.SHA512, RSASignaturePadding.Pkcs1);
var signature = Convert.ToBase64String(signedBuffer, Base64FormattingOptions.None);
var requestBody = new SwishPayoutRequestBody
{
Payload = payload,
Signature = signature
};
签名使用C#与SWISH API合作的经验吗?
谢谢!
I am trying to send a payload to Swish (Swedish payment system), using TLS- and signing certificates. I am currently working with the Merchant Swish Simulator and using test-certificates from Swish documentation.
When sending the payload and signature (to endpont /api/v1/payouts) I get this error:
{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Tue, 12 Apr 2022 07:02:19 GMT
Server: openresty/1.15.8.3
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Transfer-Encoding: chunked
Content-Type: application/json
}}
The code below is used to generate the signature
var payloadJson = JsonConvert.SerializeObject(payload, Formatting.None, serializerSettings);
var payloadJsonBuffer = Encoding.UTF8.GetBytes(payloadJson);
using var sha512 = SHA512.Create();
var hashedBuffer = sha512.ComputeHash(payloadJsonBuffer);
using var rsa = signCert.GetRSAPrivateKey();
var signedBuffer = rsa.SignHash(hashedBuffer, HashAlgorithmName.SHA512, RSASignaturePadding.Pkcs1);
var signature = Convert.ToBase64String(signedBuffer, Base64FormattingOptions.None);
var requestBody = new SwishPayoutRequestBody
{
Payload = payload,
Signature = signature
};
Does anyone have an idea to how to approach this issue or have any experience with working with Swish API using c#?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论