Skip to content

syncing release 3.1 branch with main #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion AzureKeyVault/AzureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
logger.LogTrace("Using a service principal to authenticate, generating the credentials");
cred = new ClientSecretCredential(VaultProperties.TenantId, VaultProperties.ClientId, VaultProperties.ClientSecret, new ClientSecretCredentialOptions() { AuthorityHost = AzureCloudEndpoint, AdditionallyAllowedTenants = { "*" } });
logger.LogTrace("generated credentials", cred);
}
}
_certClient = new CertificateClient(new Uri(VaultProperties.VaultURL), credential: cred);

return _certClient;
Expand Down Expand Up @@ -236,8 +236,18 @@
public virtual async Task<KeyVaultCertificateWithPolicy> GetCertificate(string alias)
{
KeyVaultCertificateWithPolicy cert = null;
logger.LogTrace($"Attempting to retreive certificate with alias {alias} from the KeyVault.");

try { cert = await CertClient.GetCertificateAsync(alias); }
catch (RequestFailedException rEx)
{
if (rEx.ErrorCode == "CertificateNotFound")
{
// the request was successful, the cert does not exist.
logger.LogTrace("The certificate was not found.");
return null;
}
}
catch (Exception ex)
{
logger.LogError($"Error retreiving certificate with alias {alias}. {ex.Message}", ex);
Expand Down Expand Up @@ -284,7 +294,7 @@
return inventoryItems;
}

public virtual async Task<(List<string>, List<string>)> GetVaults()

Check warning on line 297 in AzureKeyVault/AzureClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 297 in AzureKeyVault/AzureClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var vaultNames = new List<string>();
var warnings = new List<string>();
Expand Down
7 changes: 5 additions & 2 deletions AzureKeyVault/AzureKeyVault.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -23,7 +23,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.3" />
<PackageReference Include="Azure.Core" Version="1.40.0" />
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Azure.ResourceManager" Version="1.12.0" />
<PackageReference Include="Azure.ResourceManager.KeyVault" Version="1.2.3" />
<PackageReference Include="Azure.ResourceManager.Resources" Version="1.7.3" />
Expand All @@ -39,6 +40,8 @@
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="0.7.0" />
<PackageReference Include="Keyfactor.Platform.IPAMProvider" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.61.3" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.61.3" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions AzureKeyVault/Jobs/Management.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ protected virtual JobResult PerformAddition(string alias, string pfxPassword, st
if (!overwrite)
{
logger.LogTrace($"checking for an existing cert with the alias {alias}");
var existing = AzClient.GetCertificate(alias);
if (existing != null && !overwrite)
var existing = AzClient.GetCertificate(alias).Result;
if (existing != null)
{
var message = $"A certificate named {alias} already exists and the overwrite checkbox was unchecked. No action was taken.";
logger.LogWarning(message);
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
- - 3.1.4
- 3.1.5
- Bug fix for error when adding new cert and overwrite is unchecked

- 3.1.4
- Update nuget dependencies (Azure Identity Packages)

- - 3.1.3
- 3.1.3
- Discovery now continues the search if an error is encountered during the process.
- Fixed issue with overwrite box check being ignored when replacing cert in Keyvault
- Now getting properties of certs as pageable during inventory to fix a timeout issue when querying for thousands of certs.
Expand Down
Loading