Skip to content

Commit

Permalink
Merge 41de1cd into 1349696
Browse files Browse the repository at this point in the history
  • Loading branch information
leefine02 authored Aug 14, 2024
2 parents 1349696 + 41de1cd commit 6669011
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.1.2
* Fix bug identifying private key entry when certificate and key file names differ

2.1.1
* Fix issue identifying whether inventoried certificate contains a private key.
* Renewing Unbound Certificates Causes The Job To Fail
Expand Down
7 changes: 6 additions & 1 deletion CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,12 @@ public X509Certificate2 GetX509Certificate(string fileLocation, out bool hasKey)
try
{
var fileNameWithoutExtension = fileLocation;
if (fileLocation.EndsWith(".crt",StringComparison.CurrentCultureIgnoreCase) || fileLocation.EndsWith(".pem", StringComparison.CurrentCultureIgnoreCase) || fileLocation.EndsWith(".pfx", StringComparison.CurrentCultureIgnoreCase) || fileLocation.EndsWith(".cert", StringComparison.CurrentCultureIgnoreCase) || fileLocation.EndsWith(".der", StringComparison.CurrentCultureIgnoreCase))
if (fileLocation.EndsWith(".crt",StringComparison.CurrentCultureIgnoreCase) ||
fileLocation.EndsWith(".cer", StringComparison.CurrentCultureIgnoreCase) ||
fileLocation.EndsWith(".pem", StringComparison.CurrentCultureIgnoreCase) ||
fileLocation.EndsWith(".pfx", StringComparison.CurrentCultureIgnoreCase) ||
fileLocation.EndsWith(".cert", StringComparison.CurrentCultureIgnoreCase) ||
fileLocation.EndsWith(".der", StringComparison.CurrentCultureIgnoreCase))
{
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileLocation);
}
Expand Down
23 changes: 21 additions & 2 deletions CitrixAdcOrchestratorJobExtension/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ private string ResolvePamField(string name, string value)
private JobResult ProcessJob(CitrixAdcStore store, InventoryJobConfiguration jobConfiguration, SubmitInventoryUpdate submitInventoryUpdate)
{
_logger.LogDebug("Begin New Bindings Fix Inventory...");
_logger.LogTrace($"##### ClientMachine: {jobConfiguration.CertificateStoreDetails.ClientMachine}");
_logger.LogTrace($"##### StorePath:{jobConfiguration.CertificateStoreDetails.StorePath}");

List<CurrentInventoryItem> inventory = new List<CurrentInventoryItem>();

Expand All @@ -99,6 +101,9 @@ private JobResult ProcessJob(CitrixAdcStore store, InventoryJobConfiguration job
//create a lookup by cert(alias) for certkey identifier
Dictionary<string, string> keyPairMap = keyPairList.ToDictionary(i => i.cert, i => i.certkey);

foreach (KeyValuePair<string, string> keyPair in keyPairMap)
_logger.LogTrace($"##### keyPairMap item: Key:{keyPair.Key}, Value:{keyPair.Value}");

_logger.LogDebug("For each file get contents by alias...");
foreach (string s in contentsToCheck)
{
Expand All @@ -107,16 +112,30 @@ private JobResult ProcessJob(CitrixAdcStore store, InventoryJobConfiguration job

if (x == null) continue;

_logger.LogTrace($"##### privateKeyEntry: {privateKeyEntry.ToString()}");
if (!privateKeyEntry)
{
var certKey = keyPairList.FirstOrDefault(p => p.cert == s);
_logger.LogTrace($"##### certKey: {certKey}");
privateKeyEntry = certKey != null && !string.IsNullOrEmpty(certKey.key);
}
_logger.LogTrace($"##### privateKeyEntry: {privateKeyEntry.ToString()}");

processedAliases.Add(s);

Dictionary<string, object> parameters = new Dictionary<string, object>();

var containsKeyWithPath = keyPairMap.ContainsKey(store.StorePath + "/" + s);
string tempStorePath = store.StorePath.Substring(store.StorePath.Length-1,1) == "/" ? store.StorePath : store.StorePath + "/";
var containsKeyWithPath = keyPairMap.ContainsKey(tempStorePath + s);
var containsKey = keyPairMap.ContainsKey(s);

_logger.LogTrace($"##### containsKeyWithPath: {containsKeyWithPath.ToString()}");
_logger.LogTrace($"##### containsKey: {containsKey.ToString()}");


if (containsKey || containsKeyWithPath)
{
var keyPairName = containsKeyWithPath ? keyPairMap[store.StorePath + "/" + s] : keyPairMap[s];
var keyPairName = containsKeyWithPath ? keyPairMap[tempStorePath + s] : keyPairMap[s];

_logger.LogDebug($"Found keyPairName: {keyPairName}");
parameters.Add("keyPairName", keyPairName);
Expand Down

0 comments on commit 6669011

Please sign in to comment.