PayNL.RequestSigning
1.1.0.1
See the version list below for details.
dotnet add package PayNL.RequestSigning --version 1.1.0.1
NuGet\Install-Package PayNL.RequestSigning -Version 1.1.0.1
<PackageReference Include="PayNL.RequestSigning" Version="1.1.0.1" />
paket add PayNL.RequestSigning --version 1.1.0.1
#r "nuget: PayNL.RequestSigning, 1.1.0.1"
// Install PayNL.RequestSigning as a Cake Addin #addin nuget:?package=PayNL.RequestSigning&version=1.1.0.1 // Install PayNL.RequestSigning as a Cake Tool #tool nuget:?package=PayNL.RequestSigning&version=1.1.0.1
Request Signing
This package adds functionality to sign & verify requests sent by the Pay. platform.
Usage
The RequestSigningService
simplifies both signing and verifying requests, avoiding the need for manual class instantiation.
The constructor function of this service requires an array of SingingMethods that you wish to support. Each signing method has different needs and functionality, and which one(s) you opt to support falls under your discretion.
By providing the service with the array of these chosen methods, the service can handle the configuration and functionality. This decouples the setup process from your main application logic, allowing a more streamlined integration.
Signing
The below code snippet shows the basis of singing a request using this package:
using PayRequestSigningSdk;
// Generate
var signingService = new RequestSigningService(new List<IRequestSigningMethod>()
{
new HmacSignature(new SignatureKeyRepository() ),
});
var request = new HttpRequestMessage(new HttpMethod("POST"), "http://scenius.nl");
var signed = signingService.Sign(request, "key", "sha512", "HMAC");
Console.WriteLine($"Signature: {signed.Headers.GetValues(IRequestSigningMethod.SIGNATURE_HEADER).First()}");
Verify
The below code snippet shows the basis of verifying a request signed using the above-mentioned method:
using PayRequestSigningSdk;
var signingService = new RequestSigningService(new List<IRequestSigningMethod>()
{
new HmacSignature(new SignatureKeyRepository() ),
});
var verified = signingService.Verify(signed);
Console.WriteLine($"Verify result: {verified}");
Exception handling
The request signing service and the underlying signing / verifying methods may throw exceptions when unexpected values are encountered, these are:
- SignatureKeyNotFound, this exception must be thrown when the implementation of the
ISignatureKeyRepository
can not find the key based on the provided id; - UnknownSigningMethodException, this exception will be thrown by the singing / verifying methods when they are requested to sign / verify a request with an algorithm they do not support;
- UnsupportedHashingAlgorithmException, this exception will be thrown by the
RequestSigningService
when it is requested to sign / verify a request with a method it doesn't support.
Supported Signing / Verifying methods
HMAC
The HmacSignature
class enables the signing and verification of requests made with HMAC signatures.
To utilize this class's method, a single argument is required for its constructor. This argument is of type IHmacSignatureKeyRepository
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
First release