Skip to content

Commit 2cea4cb

Browse files
including certificate policy with options when writing to KeyVault.
1 parent e5d69ff commit 2cea4cb

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

AzureKeyVault/AzureClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public virtual async Task<KeyVaultResource> CreateVault()
199199
}
200200
}
201201

202-
public virtual async Task<KeyVaultCertificateWithPolicy> ImportCertificateAsync(string certName, string contents, string pfxPassword, Dictionary<string,string> tags, bool nonExportable)
202+
public virtual async Task<KeyVaultCertificateWithPolicy> ImportCertificateAsync(string certName, string contents, string pfxPassword, Dictionary<string, string> tags, bool nonExportable)
203203
{
204204
try
205205
{
@@ -221,7 +221,7 @@ public virtual async Task<KeyVaultCertificateWithPolicy> ImportCertificateAsync(
221221
logger.LogTrace($"calling ImportCertificateAsync on the KeyVault certificate client to import certificate {certName}");
222222

223223
var options = new ImportCertificateOptions(certName, p12bytes);
224-
options.Policy.Exportable = nonExportable;
224+
options.Policy = new CertificatePolicy { Exportable = !nonExportable, ContentType = CertificateContentType.Pkcs12 };
225225

226226
if (tags.Any())
227227
{
@@ -389,7 +389,7 @@ public virtual (List<string>, List<string>) GetVaults()
389389
var warning = $"Exception thrown performing discovery on tenantId {searchTenantId} and subscription ID {searchSubscription}. Exception message: {ex.Message}";
390390

391391
logger.LogWarning(warning);
392-
warnings.Add(warning);
392+
warnings.Add(warning);
393393
}
394394

395395
return (vaultNames, warnings);

AzureKeyVault/Jobs/Management.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using Keyfactor.Orchestrators.Extensions.Interfaces;
1818
using System.Collections.Generic;
1919
using Newtonsoft.Json;
20-
using System.Security.AccessControl;
2120

2221
namespace Keyfactor.Extensions.Orchestrator.AzureKeyVault
2322
{
@@ -140,16 +139,16 @@ protected virtual JobResult PerformAddition(string alias, string pfxPassword, st
140139
if (existing != null)
141140
{
142141
logger.LogTrace($"there is an existing cert..");
143-
}
144142

145-
existingTags = existing?.Properties.Tags as Dictionary<string, string> ?? new Dictionary<string, string>();
143+
existingTags = existing?.Properties.Tags as Dictionary<string, string> ?? new Dictionary<string, string>();
146144

147-
logger.LogTrace("existing cert tags: ");
148-
if (!existingTags.Any()) logger.LogTrace("(none)");
145+
logger.LogTrace("existing cert tags: ");
146+
if (!existingTags.Any()) logger.LogTrace("(none)");
149147

150-
foreach (var tag in existingTags)
151-
{
152-
logger.LogTrace(tag.Key + " : " + tag.Value);
148+
foreach (var tag in existingTags)
149+
{
150+
logger.LogTrace(tag.Key + " : " + tag.Value);
151+
}
153152
}
154153

155154
// if overwrite is unchecked, check for an existing cert first

integration-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
},
5050
{
5151
"Name": "NonExportable",
52-
"DisplayName": "Non Exportable",
53-
"Description": "If true, this will mark the certificate as 'non-exportable' when importing into Azure KeyVault",
52+
"DisplayName": "Non Exportable Private Key",
53+
"Description": "If true, this will mark the certificate as having a non-exportable private key when importing into Azure KeyVault",
5454
"Type": "Bool",
5555
"DefaultValue": "False",
5656
"RequiredWhen": {

0 commit comments

Comments
 (0)