Skip to content

Commit

Permalink
ab#61881
Browse files Browse the repository at this point in the history
  • Loading branch information
leefine02 authored and leefine02 committed Aug 14, 2024
1 parent aa2f65c commit 41de1cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
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
17 changes: 15 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,22 +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 41de1cd

Please sign in to comment.