Skip to content

Commit b7d3998

Browse files
Merge pull request #16 from SendSafely/v4.0.1
v4.0.1
2 parents 18cdd34 + b2182de commit b7d3998

4 files changed

Lines changed: 93 additions & 81 deletions

File tree

SampleConsoleApplication/SendSafelyConsoleApplication.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<Prefer32Bit>false</Prefer32Bit>
4444
</PropertyGroup>
4545
<ItemGroup>
46-
<Reference Include="SendsafelyAPI, Version=4.0.0, Culture=neutral, processorArchitecture=MSIL">
46+
<Reference Include="SendsafelyAPI, Version=4.0.1, Culture=neutral, processorArchitecture=MSIL">
4747
<SpecificVersion>False</SpecificVersion>
4848
<HintPath>..\SendsafelyAPI\packages\SendsafelyAPI.dll</HintPath>
4949
</Reference>

SendsafelyAPI/SendsafelyAPI.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<AssemblyTitle>SendSafely Windows Client API</AssemblyTitle>
55
<Product>SendSafely Windows Client API</Product>
66
<Copyright>Copyright © 2024</Copyright>
7-
<AssemblyVersion>4.0.0</AssemblyVersion>
8-
<FileVersion>4.0.0</FileVersion>
7+
<AssemblyVersion>4.0.1</AssemblyVersion>
8+
<FileVersion>4.0.1</FileVersion>
99
<Platforms>AnyCPU</Platforms>
1010
</PropertyGroup>
1111
<PropertyGroup>
@@ -22,7 +22,7 @@
2222
<FileAlignment>512</FileAlignment>
2323
<TargetFrameworkProfile />
2424
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
25-
<Version>4.0.0</Version>
25+
<Version>4.0.1</Version>
2626
</PropertyGroup>
2727
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2828
<DebugSymbols>true</DebugSymbols>
@@ -63,4 +63,4 @@
6363
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.0" />
6464
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
6565
</ItemGroup>
66-
</Project>
66+
</Project>

SendsafelyAPI/Utilities/CryptUtility.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,26 @@ public String EncryptKeycode(String publicKeyStr, String unencryptedKeycode)
206206
{
207207
foreach(PgpPublicKey publicKey in pgpPub.GetPublicKeys())
208208
{
209-
if (publicKey.IsEncryptionKey)
209+
if (publicKey.IsEncryptionKey && CanEncrypt(publicKey.GetSignatures()))
210210
{
211211
key = publicKey;
212212
break;
213213
}
214214
}
215215
}
216-
216+
if (key == null) {
217+
foreach (PgpPublicKeyRing pgpPub in pubRings.GetKeyRings())
218+
{
219+
foreach(PgpPublicKey publicKey in pgpPub.GetPublicKeys())
220+
{
221+
if (publicKey.IsEncryptionKey)
222+
{
223+
key = publicKey;
224+
break;
225+
}
226+
}
227+
}
228+
}
217229
if (key == null)
218230
{
219231
throw new SendSafely.Exceptions.InvalidKeyException("Can't find encryption key in key ring.");
Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Configuration;
5-
using SendSafely.Exceptions;
6-
using System.Net;
7-
using SendSafely.Objects;
8-
9-
namespace SendSafely.Utilities
10-
{
11-
internal class StartupUtility
12-
{
13-
private Connection connection;
14-
15-
public StartupUtility(String host, String privateKey, String apiKey)
16-
{
17-
this.connection = new Connection(host, privateKey, apiKey);
18-
}
19-
20-
public StartupUtility(Connection connection)
21-
{
22-
this.connection = connection;
23-
}
24-
25-
public StartupUtility(String host, String privateKey, String apiKey, WebProxy proxy)
26-
{
27-
if (privateKey == null || privateKey.Length == 0)
28-
{
29-
throw new InvalidCredentialsException("The private key can't be null or empty");
30-
}
31-
else if (apiKey == null || apiKey.Length == 0)
32-
{
33-
throw new InvalidCredentialsException("The API key can't be null or empty");
34-
}
35-
36-
this.connection = new Connection(host, privateKey, apiKey, proxy);
37-
}
38-
39-
public Objects.Version VerifyVersion()
40-
{
41-
Endpoint p = ConnectionStrings.Endpoints["version"].Clone();
42-
String version = "0.3";
43-
p.Path = p.Path.Replace("{version}", version);
44-
45-
VersionResponse response = connection.Send<VersionResponse>(p);
46-
return response.Version;
47-
}
48-
49-
public String VerifyCredentials()
50-
{
51-
Endpoint p = ConnectionStrings.Endpoints["verifyCredentials"].Clone();
52-
53-
StandardResponse response = connection.Send<StandardResponse>(p);
54-
55-
if (response.Response != APIResponse.SUCCESS)
56-
{
57-
throw new InvalidCredentialsException("Failed to verify the credentials.");
58-
}
59-
60-
return response.Message;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Configuration;
5+
using SendSafely.Exceptions;
6+
using System.Net;
7+
using SendSafely.Objects;
8+
9+
namespace SendSafely.Utilities
10+
{
11+
internal class StartupUtility
12+
{
13+
private Connection connection;
14+
15+
public StartupUtility(String host, String privateKey, String apiKey)
16+
{
17+
this.connection = new Connection(host, privateKey, apiKey);
18+
}
19+
20+
public StartupUtility(Connection connection)
21+
{
22+
this.connection = connection;
23+
}
24+
25+
public StartupUtility(String host, String privateKey, String apiKey, WebProxy proxy)
26+
{
27+
if (privateKey == null || privateKey.Length == 0)
28+
{
29+
throw new InvalidCredentialsException("The private key can't be null or empty");
30+
}
31+
else if (apiKey == null || apiKey.Length == 0)
32+
{
33+
throw new InvalidCredentialsException("The API key can't be null or empty");
34+
}
35+
36+
this.connection = new Connection(host, privateKey, apiKey, proxy);
37+
}
38+
39+
public Objects.Version VerifyVersion()
40+
{
41+
Endpoint p = ConnectionStrings.Endpoints["version"].Clone();
42+
String version = "0.3";
43+
p.Path = p.Path.Replace("{version}", version);
44+
45+
VersionResponse response = connection.Send<VersionResponse>(p);
46+
return response.Version;
47+
}
48+
49+
public String VerifyCredentials()
50+
{
51+
Endpoint p = ConnectionStrings.Endpoints["verifyCredentials"].Clone();
52+
53+
StandardResponse response = connection.Send<StandardResponse>(p);
54+
55+
if (response.Response != APIResponse.SUCCESS)
56+
{
57+
throw new InvalidCredentialsException("Failed to verify the credentials.");
58+
}
59+
60+
return response.Message;
6161
}
6262

6363
public User GetUserInformation()
@@ -72,24 +72,24 @@ public User GetUserInformation()
7272
}
7373

7474
return Convert(response);
75-
}
76-
77-
public Connection GetConnectionObject()
78-
{
79-
return this.connection;
80-
}
81-
82-
private User Convert(UserInformationResponse response)
83-
{
75+
}
76+
77+
public Connection GetConnectionObject()
78+
{
79+
return this.connection;
80+
}
81+
82+
private User Convert(UserInformationResponse response)
83+
{
8484
User user = new User();
8585
user.AllowPublicKey = response.AllowPublicKey;
8686
user.ClientKey = response.ClientKey;
8787
user.Email = response.Email;
8888
user.FirstName = response.FirstName;
8989
user.Id = response.Id;
9090
user.LastName = response.LastName;
91-
user.PackageLife = response.PackageLife;
92-
return user;
93-
}
94-
}
95-
}
91+
user.PackageLife = response.PackageLife;
92+
return user;
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)