Skip to content
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

Ab#61881 #30

Closed
wants to merge 2 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
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
Loading