Skip to content

Commit

Permalink
improved exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mLicznerskiIterative committed Feb 4, 2021
1 parent 9923afd commit a6c5fb3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Various .NET Client libraries for utilization of APIs in [AdScore.com](https://adscore.com)

##### Latest version: 1.0.1 - currently available features:
##### Latest version: 1.0.2 - currently available features:
1. SignatureVerifier

##### other languages:
Expand All @@ -13,7 +13,7 @@ Various .NET Client libraries for utilization of APIs in [AdScore.com](https://a
### Installation

```
Install-Package AdScore.Signature -Version 1.0.1
Install-Package AdScore.Signature -Version 1.0.2
```

Or by downloading .nuget file need from releases and provided from local "Packages Folder"
Expand All @@ -28,6 +28,7 @@ https://docs.microsoft.com/pl-pl/nuget/reference/nuget-config-file
|---------------------------------------------------|------|
|[1.0.0](https://github.com/Adscore/client-libs-net)|>= 1.6|
|[1.0.1](https://github.com/Adscore/client-libs-net)|>= 1.6|
|[1.0.2](https://github.com/Adscore/client-libs-net)|>= 1.6|

https://docs.microsoft.com/pl-pl/dotnet/standard/net-standard

Expand Down
2 changes: 1 addition & 1 deletion src/AdScore.Signature.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>AdScore.Signature</PackageId>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<TargetFramework>netstandard1.6</TargetFramework>
<RootNamespace>AdScore.Signature</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
7 changes: 6 additions & 1 deletion src/SignatureVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static SignatureVerificationResult Verify(

if (exp.Message.StartsWith(base64Exception))
{
validationResult.Error = exp.Message.Replace(base64Exception, "Key is not a valid Base-64 string");
validationResult.Error = exp.Message.Replace(base64Exception, "Key/Signature is not a valid Base-64 string");
return validationResult;
}
else
Expand Down Expand Up @@ -321,6 +321,11 @@ internal static string GetBase(

private static string FromBase64(string data)
{
if (string.IsNullOrWhiteSpace(data))
{
throw new SignatureVerificationException("empty key or signature");
}

int mod4 = data.Length % 4;
if (mod4 > 0)
{
Expand Down

0 comments on commit a6c5fb3

Please sign in to comment.