Skip to content

Commit

Permalink
Merge pull request #376 from aws/dev
Browse files Browse the repository at this point in the history
chore: release 0.26
  • Loading branch information
ganeshnj authored Oct 15, 2021
2 parents fcbdfc0 + d06fed1 commit 935f319
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/AWS.Deploy.ServerMode.Client/ServerModeHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ServerModeHttpClientAuthorizationHandler : HttpClientHandler
private readonly Func<Task<AWSCredentials>> _credentialsGenerator;
private readonly Aes? _aes;

private static readonly object AES_LOCK = new object();

internal ServerModeHttpClientAuthorizationHandler(Func<Task<AWSCredentials>> credentialsGenerator, Aes? aes = null)
{
_credentialsGenerator = credentialsGenerator;
Expand Down Expand Up @@ -73,8 +75,14 @@ public static void AddAuthorizationHeader(HttpRequestMessage request, ImmutableC
string base64;
if(aes != null)
{
aes.GenerateIV();
var encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
byte[] iv;
lock (AES_LOCK)
{
aes.GenerateIV();
iv = aes.IV;
}

var encryptor = aes.CreateEncryptor(aes.Key, iv);

using var inputStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
using var outputStream = new MemoryStream();
Expand All @@ -83,7 +91,7 @@ public static void AddAuthorizationHeader(HttpRequestMessage request, ImmutableC
inputStream.CopyTo(encryptStream);
}

base64 = $"{Convert.ToBase64String(aes.IV)} {Convert.ToBase64String(outputStream.ToArray())}";
base64 = $"{Convert.ToBase64String(iv)} {Convert.ToBase64String(outputStream.ToArray())}";
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.25",
"version": "0.26",
"publicReleaseRefSpec": [
".*"
],
Expand Down

0 comments on commit 935f319

Please sign in to comment.